catelee2u Posted October 28, 2009 Share Posted October 28, 2009 I'm trying to make a registration page that will submit the users details to my database. I am very new to php and mysql and don't know a lot of commands yet but trying to learn. I have written what I expected to work but am getting output : Parse error: syntax error, unexpected $end in /var/www/sendregister.php on line 57 (the last line) I tried getting rid of some white space hearing that can be troublesome but it still does it. I have registration.php (my form) <form action="sendregister.php" method="post"> First Name :<br /> <input type="text" name="fname" /><br /><br /> Last Name :<br /> <input type="text" name="sname" /><br /><br /> Contact Email :<br /> <input type="text" name="email" /><br /><br /> Desired Username :<br /> <input type="text" name="loginname" /><br /><br /> Password :<br /> <input type="text" type="hidden" name="loginpwd" /><br /><br/> Verify Password :<br /> <input type="text" type="hidden" name="loginpwd2" /><br /><br /> Check box to agree to our terms <input type="checkbox" name="check" value="agree" /><br /> <a href="terms.php" alt="Terms">Terms</a><br/><br /> <input type="submit" name="register" value="register" /> </form> and the code page supposed to handle form input sendregister.php <?php // Connect to Database $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } //If form is submitted this runs if (isset ($_POST['register'])) { //Check for empty form fields if (!$_POST['fname'] || !$_POST['sname'] || !$_POST['email'] || !$_POST['loginname'] || !$_POST['loginpwd'] || !$_POST['loginpwd2']) { die('You did not complete all of the required fields'); } //Check checkbox here if (!isset ($_POST['register'])) { die('You did not agree to our terms'); } //Check if login name taken mysql_select_db("shadow", $con); $potential = $_POST['loginname']; $result = ("SELECT loginname FROM members WHERE loginname = '$potential'"); $finalresult = mysql_num_rows($result); If ($finalresult != 0 ) { die ('Your desired username '.$_POST['loginname'].' is already taken - please choose another.'); } //Check passwords match $pwd1 = $_POST['loginpwd']; $pwd2 = $_POST['loginpwd2']; If ( $pwd1 != $pwd2 ) { die ('Your passwords do not match.'); } //Check password is alphanumeric $alphanumeric = $_POST['loginpwd']; If (!ctype_alnum($alphanumeric)){ die('Your password must only contain letters and numbers'); } //Encrypt passwords and insert to database $_POST['loginpwd'] = md5($_POST['loginpwd']); mysql_query("INSERT INTO members (fname, sname, email, loginname, loginpwd) VALUES ('$_POST[fname]', '$_POST[sname]', '$_POST', '$_POST[loginname]', '$_POST[loginpwd]')"); //include registration congrats page onto this page include("registered.php"); //close database mysql_close($con); ?> I have looked through this and don't know what problems there are with it though I suspect there is more than one. Thankyou in advance for any assistance, Catherine Link to comment https://forums.phpfreaks.com/topic/179294-clueless/ Share on other sites More sharing options...
xtopolis Posted October 28, 2009 Share Posted October 28, 2009 You are missing a closing brace for this line if (isset ($_POST['register'])) { There is no } for it on the page. Link to comment https://forums.phpfreaks.com/topic/179294-clueless/#findComment-945973 Share on other sites More sharing options...
catelee2u Posted October 28, 2009 Author Share Posted October 28, 2009 You are missing a closing brace for this line if (isset ($_POST['register'])) { There is no } for it on the page. Thanks I never noticed that...I have deleted the offending brace but still coming up with an error. Link to comment https://forums.phpfreaks.com/topic/179294-clueless/#findComment-945991 Share on other sites More sharing options...
xtopolis Posted October 28, 2009 Share Posted October 28, 2009 No.. you need to add a brace -- somewhere near the bottom I'm guessing. Depends on if you want to show the "registered" page or not in the same logic as isset ($_POST['register']) Link to comment https://forums.phpfreaks.com/topic/179294-clueless/#findComment-946003 Share on other sites More sharing options...
Stephen Posted October 28, 2009 Share Posted October 28, 2009 You would add a closing brace right before you close the mysql connection (after you use "include("registered.php")"). Link to comment https://forums.phpfreaks.com/topic/179294-clueless/#findComment-946017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.