nucleardoctor Posted May 2, 2007 Share Posted May 2, 2007 Im trying to make a site where when I go to add a member, it adds them to a database, but when I made this, it won't write to the database for some reason and I know that connect.phtml works because its used for other scripts that I have written and they all connect to the database. When I remove "if(isset($_POST['select']))", it does write to the database but every time when I go to refresh the page, it also puts a blank entry into the database so I can't have that happen. Does anyone see what might be going wrong? <?php include "connect.phtml"; $db="delranfire_org"; if(isset($_POST['select'])) { $query1="insert into member('name','password','email')values('$name','$password','$email')"; mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/ Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 try: if($_POST['select'] != "") Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243499 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Nope, didn't work, any other ideas? Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243509 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 You should really put this on the submit rather than the select: if(isset($_POST['submit'])) Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243510 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Nope, still didn't work on submit =/ Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243513 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 Change the filename to addmember.php and change where the form is being submitted to, to addmember.php to. Then see if it works Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243514 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Thats weird, now when I remove that line of code, it worked before where every time when I refreshed it would submit blank entries, but now its giving me an error when I remove the line of code. Error in query:. You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''name','password','email')values('','','')' at line 1 Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243516 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 The .php didn't work. Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243517 Share on other sites More sharing options...
monk.e.boy Posted May 2, 2007 Share Posted May 2, 2007 <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into member('name','password','email')values('$name','$password','$email')"; mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> Where does $name $password and $email come from? Also add: print_r( $_POST ); monk.e.boy Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243521 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Its my values that are to be submitted... or wait, do I even need them sence im not recieving any data? It says "Array ( [name] => test [password] => etest => test [submit] => Add Member )" at the top but its still not writting to the database Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243523 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 Where does $name $password and $email come from? register_globals must be off. Change $query1="insert into member('name','password','email')values('$name','$password','$email')"; to $query1="insert into member('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')"; Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243525 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 I replaced the code but nothing changed. My code updated: <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into member('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."l')"; mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243529 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 '".$_POST['email']."l' should be: '".$_POST['email']."' Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243534 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Now I get Parse error: syntax error, unexpected T_STRING in /home2/delranfd/delranfire-www/newadmin/addmember.phtml on line 11 Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243536 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 Show the code. Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243541 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into member('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."' mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243580 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 should be: <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into member('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')" mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243583 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Parse error: syntax error, unexpected T_STRING in /home2/delranfd/delranfire-www/newadmin/addmember.phtml on line 11 Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243589 Share on other sites More sharing options...
papaface Posted May 2, 2007 Share Posted May 2, 2007 This is simple PHP, put a ; at the end of: $query1="insert into member('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')" Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243593 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Still not writing :-\ Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243598 Share on other sites More sharing options...
trq Posted May 2, 2007 Share Posted May 2, 2007 $query1="insert into member (name,`password`,email) values ('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')"; Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243599 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 I just made a new database, the old one has alot of entries already and its getting boring scrolling through all of the entries to see if it posted or not, the new one is called members Updated code is below <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into members('name','password','email')values('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')"; mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Could my database be wrong? Field - ID Type - int(10) Attributes - UNSIGNED Null - No Default - Extra - auto_increment Action - --- Field - Name Type - Varchar(55) Attributes - Null - Yes Default - NULL Extra - Action - --- Field - Password Type - Varchar(55) Attributes - Null - Yes Default - NULL Extra - Action - --- Field - email Type - Varchar(55) Attributes - Null - Yes Default - NULL Extra - Action - Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243605 Share on other sites More sharing options...
trq Posted May 2, 2007 Share Posted May 2, 2007 Look at my query. Note the spaces. Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243615 Share on other sites More sharing options...
nucleardoctor Posted May 2, 2007 Author Share Posted May 2, 2007 Yea, I know I saw yours already, but it still doesn't post. <?php include "connect.phtml"; $db="delranfire_org"; print_r( $_POST ); if(isset($_POST['select'])) { $query1="insert into member (name,`password`,email) values ('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')"; mysql_query($query1) or die("Error in query:$query. " .mysql_error()); } ?> <html> <head> <title> <? include "admin_panel_title.php";?> </title> </head> <body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#FF3333" vlink="#CC0000" alink="#CC0000"> <form action="addmember.phtml" method="post"> <center> <img src="/newadmin/Administration_Panel_Banner.png"><br> <h3>Add a Member</h3> <table border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">First & Last Name: </font></b></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="name" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Password: </font></b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="password" SIZE="30"></INPUT> </td> </tr> <tr> <td width="47%" align="center" valign="middle"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>EMail Address**: </b></font></div> </td> <td width="51%" valign="middle">  <INPUT TYPE="text" NAME="email" SIZE="30"></INPUT> </td> </tr> <tr> <td colspan="3"> <div align="center"> <input type="submit" name="Submit" value="Add Member"> <input type="reset" name="reset" value="Clear Information"> </div> </td> </tr> </table> </form> <a href="/newadmin/">Back to Administration Panel</a><br> <br> <font size="2">**This field will not create an email address. The email address must be added though the CPanel </body></html> <? mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-243678 Share on other sites More sharing options...
monk.e.boy Posted May 3, 2007 Share Posted May 3, 2007 Try downloading the free program SQLog, this will let you connect to your database and test out your SQL commands. When you have them running OK, you can past the SQL into your PHP program. You need to do this else you will have these problems every time you try to change any of your SQL. <?php $query1="insert into member (Name,Password,Email) values ('".$_POST['name']."','".$_POST['password']."','".$_POST['email']."')"; echo $query1; ?> I don't know if MySQL column names are case sensitive? I've never seen anyone use capitals in them before... monk.e.boy Link to comment https://forums.phpfreaks.com/topic/49666-php-code-issues/#findComment-244123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.