+ 1

still having php troubles...please someone with clear answers help????

say i have this basic script <html> <body> <form action="contacts.php" method="post"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name="email"><br> <input type="submit"> </form> </body> </html> Now i have both the script php page and the contacts.php saved in the same folder in my xampp htdocs! when i submit info i get no kinds of errors or anything out of the ordinary .... but the info is not being processed to the contacts.php? Someone please help out with this, i need it for my subscribe page and its the only reason i have not made the page live yet is because i need this script to work!!!?????

24th May 2018, 4:43 PM
David CHAMPION
David CHAMPION - avatar
20 Réponses
+ 2
Name:<?php echo $_POST["name"]; ?> Email:<?php echo $_POST["email"]; ?> had you wrote on contact.php
24th May 2018, 5:01 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 3
Post the contacts.php page to me please. Nothing wrong with the page you posted in your description, so it's not an issue on that end. Also, what browser are you using for testing? Most browsers have a feature that'll allow you to see what is or isn't being sent out. For example, in Chrome you can right click and click on "Inspect." Then from there you can look at the 'Network' tab to see what data is being sent to contacts.php and ensure that's happening as expected.
24th May 2018, 5:02 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 3
yes as Fata1 Err0r said that code only send data from form to contact.php by method POST , Data will be gone after you close that page so if you want to save that data parma then you should send it to Database and whenever you want you can retrive from database
24th May 2018, 5:38 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
How are you so sure the problem is that it doesn't get processed by the contacts.php? Why couldn't the problem be something else? Just some questions to clearify your problem
24th May 2018, 4:54 PM
***
*** - avatar
+ 2
I think your problem is your confusion over what the contacts.php file is for. On the first page, you're using a form to obtain data from user, and when you submit, it's sending that data (via POST) to the contacts.php page. You'll need a script on the contacts.php page that handles what you want to do with that data, otherwise it's not being used in any useful way. As Shudarshan Rai showed you, it's proving that the data is being received by the Contacts.php, but you're not doing anything with it. With his example, you're simply displaying the data. So the real question, what do you want to do with the data from this form? Store it to a database? Store it to a text file? etc... Give us more information and we can help you out.
24th May 2018, 5:26 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 2
thank u ill try this
24th May 2018, 5:37 PM
David CHAMPION
David CHAMPION - avatar
+ 2
I'm in a meeting I haven't tried yet ill let u lnow either way
24th May 2018, 7:03 PM
David CHAMPION
David CHAMPION - avatar
+ 2
@David Woods Understood completely. I'm at work also, but shift is nearing its end. I'll check back in later.
24th May 2018, 7:37 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
I want to save the emails so I can send them updates and news
24th May 2018, 5:32 PM
David CHAMPION
David CHAMPION - avatar
+ 1
Its not working at all now this is getting frustrating i just want users to subscribe to my page..save the emails to a file for me....
24th May 2018, 5:57 PM
David CHAMPION
David CHAMPION - avatar
+ 1
contacts.php: <?PHP $userName = $_POST['name']; $userEmail = $_POST['email']; $mailingList = fopen("mailinglist.txt", "a") or die("Cannot open file."); fwrite($mailingList , $userName . " - " . $userEmail); fclose($mailingList); ?> ^Try something like that. It should open/create the file, store the username/email, and then close the file. I'm not in a position to test it, so if it doesn't work, let me know and I'll fix.
24th May 2018, 6:18 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
ill try it and let u know
24th May 2018, 6:22 PM
David CHAMPION
David CHAMPION - avatar
+ 1
Okay cool. Let me know how it goes. If I need to remote into my web server and test for you, I can do that. It should create and save the file in the same location as your contacts.php file. So once you do this, refresh that folder and see if it's there. If it is, try to open and see if the data is there. That'll let you know if it's working since we didn't put in any type of confirmation (which you'll want to add later when its working).
24th May 2018, 6:24 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
@David Woods Since you didn't come back, I'm assuming all went well?
24th May 2018, 7:02 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
@fatal error it is still not working, im trying to do with just email as well and nothing!
24th May 2018, 8:53 PM
David CHAMPION
David CHAMPION - avatar
+ 1
@fatal error it is still not working, im trying to do with just email as well and nothing!
24th May 2018, 8:54 PM
David CHAMPION
David CHAMPION - avatar
+ 1
@fatal error still nothing...so here is the new form i wrote for the html page <form action="contacts.php" method="post"> E-mail: <input type="text" name="email" placeholder="Subscribe to our page for the latest News & Updates"> <input type="submit" value="Subscribe" > </form> then i just need to pass the info to a contacts.php txt file.... i cant find it anywhere online or anything..so if just say my contacts.php has absolutely no code in it...now u have my html form code...what would your next script be for contacts.php?
24th May 2018, 9:00 PM
David CHAMPION
David CHAMPION - avatar
0
@Fata1 Err0r the contacts.php page is just a page from notepad saved as contacts.php should there be a script on that as well? the browser i use is firefox.....
24th May 2018, 5:12 PM
David CHAMPION
David CHAMPION - avatar
0
@Shudarshan Rai 👑 i wrote that Name:<?php echo $_POST["name"]; ?> Email:<?php echo $_POST["email"]; ?> on the contacts.php and when submittting its now showing the info just not saving it....? like when i go to open my contacts.php file its not there , but when i submit it shows the email and name submitted on the page...
24th May 2018, 5:23 PM
David CHAMPION
David CHAMPION - avatar