Posted on Sunday 9th November 2008 at 05:57 PM | |
setsukemizuhara Newbie |
PHP Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?
Parse error: parse error, unexpected $ in /home/www/requiemofdestiny.awardspace.com/register.php on line 48 It's annoying... |
Posted on Sunday 9th November 2008 at 06:03 PM | |
Dava Active Member |
Code <? // Include data base connection include("dbconnect.php"); // Check for form submission if(isset($_REQUEST['submit'])) { // Check for empty fields if(empty($_REQUEST['username'])||empty($_REQUEST['password'])||empty($_REQUEST['cpassword'])||empty($_REQUEST['email'])) { // Cancel the register process and display error echo "Some fields are not filled out."; } else { // If fields are not empty // Set varibles for submitted data $username = $_REQUEST['username']; $password = $_REQUEST['password']; $cpassword = $_REQUEST['cpassword']; $email = $_REQUEST['email']; $ip = $_SERVER['REMOTE_ADDR']; } // Check if username already exists $sql1 = "SELECT * FROM `user` WHERE `username`='$username'"; $result1 = mysql_num_rows($result); if($result1 == 1) { //If username exists echo "Username already exists."; } // Check if submitted passwords are the same if($password != $cpassword) { //Passwords do not match, display error echo "Passwords do not match."; } // If username does not exist and passwords match // Encrypt password for database storage $spw = md5($password); // Insert data into database $sql2 = "INSERT INTO `users` (`username`,`password`,`email`,`ip`) VALUES ('$username','$spw','$email','$ip')"; $query1 = mysql_query($sql2); // Redirect if query runs correctly header("location: http://requiemofdestiny.awardspace.com/confirmed.php"); // Change to whatever you want the redirected apge to be } ?> der ya go problem solved |
Posted on Sunday 9th November 2008 at 06:10 PM | |
setsukemizuhara Newbie |
Ok, error is gone but it is not entering the data into my site DB and it just gives a blank screen not redirecting... |
Posted on Sunday 9th November 2008 at 06:12 PM | |
ShadowMage Senior Member |
Change Code $query1 = mysql_query($sql2); To Code $query1 = mysql_query($sql2) or die(mysql_error()); |
Posted on Sunday 9th November 2008 at 10:24 PM | |
setsukemizuhara Newbie |
PHP Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
<?php
An edited version of the register I posted. Error: Parse error: parse error, unexpected $ in /home/www/requiemofdestiny.awardspace.com/register.php on line 81 But line 81 is the ?> and 80 is blank. |
Posted on Sunday 9th November 2008 at 11:19 PM | |
Dava Active Member |
Code <?php // Start Sessions session_start(); // Include dbconnect.php include("dbconnect.php"); // Check if form was submitted if(!$_POST['create']) {// Form wasn't submitted // Echo the Form echo " <form method=\"post\"> <table width=\"300px\" border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\"> <tr> <td colspan=\"4\"><div align=\"center\">Register</div></td> </tr> <tr> <td colspan=\"2\"><div align=\"right\">Username:</div></td> <td colspan=\"2\"><input type=\"text\" name=\"username\" id=\"username\"></td> </tr> <tr> <td colspan=\"2\"><div align=\"right\">Password:</div></td> <td colspan=\"2\"><input type=\"text\" name=\"password\" id=\"password\"></td> </tr> <tr> <td colspan=\"2\"><div align=\"right\">Confirm Password:</div></td> <td colspan=\"2\"><input type=\"text\" name=\"cpassword\" id=\"cpassword\"></td> </tr> <tr> <td colspan=\"2\"><div align=\"right\">E-mail:</div></td> <td colspan=\"2\"><input type=\"text\" name=\"email\" id=\"email\"></td> </tr> <tr> <td width=\"100\"><input name=\"ip\" type=\"hidden\" id=\"ip\" value=\"<?php echo $_SERVER[REMOTE_ADDR]; ?>\"></td> <td colspan=\"2\"><div align=\"center\"> <input type=\"submit\" name=\"create\" id=\"create\" value=\"Create\"> </div></td> <td width=\"100\"> </td> </tr> </table> </form> "; } else { // Form Was Submitted // Check if form is empty if(empty($_POST['username'])||empty($_POST['password'])||empty($_POST['cpassword'])||empty($_POST['email'])) { echo "Please fill in all form data."; } else { // Collect Form Data $username = $_POST['username']; $password = $_POST['password']; $cpassword = $_POST['cpassword']; $email = $_POST['email']; $ip = $_POST['ip']; // Check if submitted data is already in Database $checkuiuser = mysql_query("SELECT * FROM `users` WHERE `username='$username'") or die(mysql_error()); $checkuiuserc = mysql_num_rows($checkuiuser); $checkuiemail = mysql_query("SELECT * FROM `users` WHERE `email`='$email'") or die(mysql_error()); $checkuiemailc = mysql_num_rows($checkuiemail); } // Run if statement for checking if($checkuiuserc > 0 || $checkuiemail > 0) { // Username or Email exists in DB echo " Username or Email already in use."; } if ($cpassword != $password) { // Check if pass word match echo "Password do not match"; } $uiencryptpass = md5($password); $uiinsert = mysql_query("INSERT INTO `users` (`username`,`password`,`email`,`ip`,`userlvl`) VALUES ('$username','$uiencryptpass','$email','$ip','1'"); echo "You have been Registered."; } ?> just remember you do need to end functions |