Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,208,036 members, 8,001,189 topics. Date: Wednesday, 13 November 2024 at 06:06 AM |
Nairaland Forum / Science/Technology / Programming / PHP Programmers, Please I Am Cofused With This Code (596 Views)
I Need Explanation On This Code?? Php Programmers / Programmers, Please Your Golden Advise Is Needed / Programmers, Please Recommend A Good Laptop For Me. (2) (3) (4)
PHP Programmers, Please I Am Cofused With This Code by Nobody: 11:17am On Oct 18, 2020 |
Hello, i don't know if you guys are familiar with this code. This is a code that receives information from information from a form and send the information to an email address (luckyst@hotmail.com). The problem now is that this code was working before perfectly with my html code. But since yesterday it is not working. I am not good at coding and just copied the code from somewhere Please what i want to ask is what went wrong. |
Re: PHP Programmers, Please I Am Cofused With This Code by femmix112(m): 11:34am On Oct 18, 2020 |
Your code use the foreach loop with out the ; to close it and no bracket to enclose it which i think is wrong but if it works initially and stopped working with no one tampering with the code leave it check server settings or contact customer care... Or type the code in stackoverflow they will help |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 11:40am On Oct 18, 2020 |
Thanks for the help bro, i even uploaded it in another Cpanel, yet it didn't work. I dont know what stopped it but i am very sure that it is the same code. femmix112: |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 11:48am On Oct 18, 2020 |
You didnt use validation, I can see $IP variable inside quote. Op this code never runned before, use if(Isset ) to validation if the values were set. |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 11:51am On Oct 18, 2020 |
Please i am new to programming. can you send me the code so i can try it immediately supportnija: |
Re: PHP Programmers, Please I Am Cofused With This Code by Jas80: 11:52am On Oct 18, 2020 |
okochaik: what error are you getting |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 11:56am On Oct 18, 2020 |
okochaik:Op I am not close to my laptop, just go stack overflow .com coppy this code there, somebody will respond quickly |
Re: PHP Programmers, Please I Am Cofused With This Code by Jas80: 12:00pm On Oct 18, 2020 |
okochaik: there are alot of errors in the code bro. First of all you are assigning the values of post['id'] and post['pd'] to variables, without using isset for the submit button. And by the way, are you sure the name of the input field are id and pd respectively? |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:01pm On Oct 18, 2020 |
I wasn't giving any error log |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:02pm On Oct 18, 2020 |
Okay, i will do it right away supportnija: |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:03pm On Oct 18, 2020 |
I didn't get any error log Jas80: |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:13pm On Oct 18, 2020 |
I am sure the names in the inputs are id and pd. This code worked perfectly 3 days ago, but since yesterday is no longer works. Jas80: |
Re: PHP Programmers, Please I Am Cofused With This Code by Jas80: 12:23pm On Oct 18, 2020 |
okochaik: what is the name for the submit button |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:27pm On Oct 18, 2020 |
okochaik:Op try to protect your code from simple SQL injection, op even it is working don't upload it. Protect it first 1 Like |
Re: PHP Programmers, Please I Am Cofused With This Code by 404Dev: 12:31pm On Oct 18, 2020 |
So many errors. Most obvious is how you convert you $send variable to an array by just calling the array construct. You need to use the explode function. And also someone mentioned you wrap the whole code in an if issect just to make sure it only runs when the form is actually submitted. P.S I could rewrite the code for you later in the day when free. |
Re: PHP Programmers, Please I Am Cofused With This Code by 404Dev: 12:35pm On Oct 18, 2020 |
And I would advice you replace line 5 with $ip = $_SERVER['REMOTE_ADDR']; as get_env doesn't work properly on some servers 1 Like |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:50pm On Oct 18, 2020 |
Okay i will do that and make changes supportnija: |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 12:57pm On Oct 18, 2020 |
I tried it but it didn't work. Is there any other thing that i needed to edit if i add the code you gave me? 404Dev: |
Re: PHP Programmers, Please I Am Cofused With This Code by 404Dev: 1:06pm On Oct 18, 2020 |
okochaik:What exactly is not working? The mail sending? Or is any errors or warnings showing? And can you also share the html form. |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 2:07pm On Oct 18, 2020 |
The mail sending is not working. So if someone click on submit it will not poste the username and passward to the email i provided. It worked for 2 days and stopped without any changes made 404Dev: |
Re: PHP Programmers, Please I Am Cofused With This Code by vezycash(m): 3:00pm On Oct 18, 2020 |
I've not done php in over 10 years but your issue is most likely in the foreach loop. Doesn't look right to me. foreach($yourAarray as $val){ ... } $val is not an array / should not be an array. It's a single item from $yourArray array. Also $val is not a variable declared elsewhere. It's created only inside the foreach loop. Run this example code so you'll understand it better $colors = array("red", "green", "blue", "yellow" ) //put semi colon here. Nairaland changes it to emoji $count = 0; foreach ($colors as $value) { echo "$value array[$count]<br>"; count++; } Google php foreach. I'd post a link but nairaland bot randomly deletes posts containing links. |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 6:58pm On Oct 18, 2020 |
I tried this, bro and it didn't work. What keeps confusing me is that the same code was working excellently well 3 days ago. Then yesterday it stopped working until now. I have changed many alternative codes but It didn't work. I even used another cpanel but same story vezycash: |
Re: PHP Programmers, Please I Am Cofused With This Code by oyolohi: 8:38pm On Oct 18, 2020 |
$send = "xx@x.com, yy@y.com" is a string. Replace array($send) with explode(",", $send) Or simply do this: $send = ["xx@x.com", "yy@y.com"]; and delete the $send = array($send) line. Advise: Use PHPMailer instead of that mail() mail() is just so annoying... And your email just ends up in your client's spam folder. I remember the frustrations I had with mail() those days... Sometimes it just failed without warnings or errors. Until I discovered PHPMailer. 1 Like |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 10:09am On Oct 19, 2020 |
Hello thanks. Now the code is working. The problem was the cpanel that I used. Now it started working again. oyolohi: 1 Like |
Re: PHP Programmers, Please I Am Cofused With This Code by Nobody: 10:09am On Oct 19, 2020 |
Thanks all for the help!! |
Re: PHP Programmers, Please I Am Cofused With This Code by 404Dev: 10:11am On Oct 19, 2020 |
okochaik:cheers! |
(1) (Reply)
5-weeks Intensive Virtual Coding Bootcamp With Scholarship Plus Other Support. / How Many Pages Should Google Index In 3 Months / Lollzzzz, I'm Now A C++ Master
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 1 |