skbanta Posted January 9, 2008 Author Share Posted January 9, 2008 I have 7 fields that need to be filled out for the registration form though, shouldn't each fill one field? Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435014 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Yes, but this line is only inserting 2 of them, you need to add the others to it. $insert = mysql_query("insert into $table values ('', '".$_POST['username']."', '".$_POST['password']."')") or die("Could not insert data because ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435019 Share on other sites More sharing options...
skbanta Posted January 9, 2008 Author Share Posted January 9, 2008 I added the rest of my fields and now come up with this error: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/www/bantaproject.100webspace.net/register.php on line 26 This is my code: // insert the data $insert = mysql_query("insert into $table values ('', '".$_POST['username']."', '".$_POST['password']."','".$_POST['email']."','".$_POST['address']"','".$_POST['city']"',' ".$_POST['state']"','".$_POST['zip']"')") or die("Could not insert data because ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435029 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 I cannot seem to figure out what to fix in the script. Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435201 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 // insert the data $insert = mysql_query("insert into $table values ('', '".$_POST['username']."', '".$_POST['password']."','".$_POST['email']."','".$_POST['address']"','".$_POST['city']"',' ".$_POST['state']"','".$_POST['zip']."')") or die("Could not insert data because ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435204 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 // insert the data $insert = mysql_query("insert into $table values ('', '".$_POST['username']."', '".$_POST['password']."','".$_POST['email']."','".$_POST['address']"','".$_POST['city']"',' ".$_POST['state']"','".$_POST['zip']."')") or die("Could not insert data because ".mysql_error()); I added this and all the periods after each post, but now I get "Could not insert data because Column count doesn't match value count at row 1" again. I am truly stumped as to what to do. Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435219 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 // insert the data $insert = mysql_query("insert into $table values ('".$_POST['username']."', '".$_POST['password']."','".$_POST['email']."','".$_POST['address']"','".$_POST['city']"',' ".$_POST['state']"','".$_POST['zip']."')") or die("Could not insert data because ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435221 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 Ok, thanks a lot for that part, I got the database to work, but now the log in wont work. it comes up with this error: "Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/www/bantaproject.100webspace.net/login.php on line 26" here is the log-in code: <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, your username or password is incorrect.<br>"; echo "<a href=index.html>Try again</a>"; echo "or"; echo "<a href=register.html>Register</a> exit; } else { setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$username"); echo "You are now logged in!<br>"; } ?> (I hope this is one of the last times I have to code a register/log in system) Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435228 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, your username or password is incorrect.<br>"; echo "<a href=index.html>Try again</a>"; echo "or"; echo "<a href=register.html>Register</a>"; exit; } else { setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$username"); echo "You are now logged in!<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435231 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 I realized I was missing a few lines with $match, so I added them, but now it is pulling up my error saying the username/password is incorrect when it is because I checked. Way to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435241 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 What's the code you're using to verify username and password? Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435243 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $match = "select id from $table where username = '".$_POST['username']."' and password = '".$_POST['password']."';"; $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, your username or password is incorrect.<br>"; echo "<a href=index.html>Try again</a>"; echo "or"; echo "<a href=register.html>Register</a>"; exit; } else { setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$username"); echo "You are now logged in!<br>"; } ?> There. Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-435961 Share on other sites More sharing options...
skbanta Posted January 10, 2008 Author Share Posted January 10, 2008 Does "mysite_username" have to change in the setcookie? Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-436035 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 Hmm...try this: Find: $match = "select id from $table where username = '".$_POST['username']."' and password = '".$_POST['password']."';"; Replace $match = "select id from $table where username = '".$_POST['username']."' and password = '".$_POST['password']."'"; Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-436050 Share on other sites More sharing options...
skbanta Posted January 11, 2008 Author Share Posted January 11, 2008 Still can't get it to work. I look in my database and the username is empty and the password is in my email. The whole row is moved one spot except id and password and username just aren't there. I had a friend register too, but only one item shows up in the table. Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-436813 Share on other sites More sharing options...
revraz Posted January 11, 2008 Share Posted January 11, 2008 What does your table layout look like? Does it have a id field? It probably doesn't match your INSERT statement. Quote Link to comment https://forums.phpfreaks.com/topic/85125-phpmysqlhtml-sign-inregister-form-problem/page/2/#findComment-436816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.