Help Me Out With Register.php - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Help Me Out With Register.php (870 Views)
| Help Me Out With Register.php by Ajax1211(op): 5:39pm On Mar 12, 2015 |
Hello, am having issues with php as usual Am creating an application and in the page where people are to register (i.e register.php page) so that their data can be stored into the database is not working. Actually every thing works well without any error but the values from the form does not get inserted into the database. here is the code after creating the form //assuming ive selected the right database and the connection is working <form action="thankyou.php method="post"> // Please no time to start typing the html form abeg </form> $username = $_POST['username']; //putting the username the user typed into the form into a variable $password = $_POST['password']; //same with the password $firstnamename = $_POST['firstname']; $query="INSERT INTO user (userid,username,password,name) VALUES ('','$username','$password','$firstname')"; mysql_query($query); Now when i fill the form and click on the submit button, the thankyou.php page runs properly and echoes the values from the form but checking the database,nothing gets inserted. Now the funny thing is that whenever i type the values directly into the sql statement, it works, let me show you $query="INSERT INTO user (userid,username,password,name) VALUES ('','ehis','pass','ehinome')"; When i type in the values i want inserted into the form, it works and gets inserted but when i try using variables that contains the values typed into a form, it does not get inserted. What could be the problem, ive being on this for days. Thanks |
| Re: Help Me Out With Register.php by Adesege(m): 6:07pm On Mar 12, 2015 |
Hey, i've already given a reply on the other thread EDIT:: [size=20pt]Do u know what's called debugging? Now let's try that. In ur 'thankyou.php', clear whatever u have there, or copy it somewhere. Then type this code: <?php . var_dump($_POST); ?> . Then where u have the form, input some random data, click on the submit button. On the thankyou.php, see if your inputs gets displayed in an array. . Also, in ur mysql_query, put mysql_query($query) or die(mysql_error()); . Try that and post the content of the var_dump. . Also, paste all the html form here so i can have a look. The problem might be from there also.[/size] Ajax1211: |
| Re: Help Me Out With Register.php by dwebdesign(m): 6:30pm On Mar 12, 2015 |
The problem is this: you want to send values to the database that you have not connected to. Thats not going to work. Soluton: Connect to the database and run the query again. Specify the database host, username and password correctly. That's the fix. Contact: Mobile: 08133884165 Whatsapp: 08133884165 BBM: 2BB63350 Contact webpage: http://www.1st-websitedesign.com Am a website developer skilled in web development languages such as php, mysql, html/css, jquery, js, jquerymobile. And an expert in content management systems such as wordpress, drupal, magento, opencart, joomla, whmcs, etc |
| Re: Help Me Out With Register.php by Adesege(m): 6:33pm On Mar 12, 2015 |
I assumed the database must have been connected to before hand. dwebdesign: |
| Re: Help Me Out With Register.php by maekhel(m): 7:26pm On Mar 12, 2015 |
Pasting ur html form code might be helpful |
| Re: Help Me Out With Register.php by Guyson(m): 11:15pm On Mar 13, 2015 |
Ajax1211:you declared the variable as $firstnamename and you inserted the VALUE as $firstname. |
| Re: Help Me Out With Register.php by matthew80(m): 5:12pm On Mar 14, 2015 |
Guyson:Thanks for noticing, bro! @OP, //Let's Debug /*********************************** 1. Make sure each <input type="text" has also name="username" ,,,as name, and not value, would be passed as php parameter /> If that's done but still no way, then try this: Editted Ajax1211:Notice the parentheses () around the $_POST[...... stuffs. Good luck! Hope this helps. |
| Re: Help Me Out With Register.php by matthew80(m): 5:17pm On Mar 14, 2015 |
dwebdesign:Check: Ajax1211: |
| Re: Help Me Out With Register.php by 53cur3m0d3(m): 12:53pm On Mar 16, 2015 |
please post your register form codes and the register. php codes here for us to look at carefully. U should take out Ur database name, username and password from the codes and replace with random strings. |
Guides In Learning Web Development • Apply For Payoneer Master Card For Free :Sign up now and earn $25* • I Will Write Quality And Seo Friendly Content For You