0

Hi im new to php, so can some body help me out with this code? "Parse error: syntax error, unexpected $end in E:\EasyPHP-5.3.2i\www\Survey\register.php on line 79"

<html>
<?php

if (isset($_POST['button'])) {
if ($button)
{   
	// get data 
    $username = $_POST['username'];
	$password = $_POST['password'];
	$retypepassword = $_POST['password'];
	$email = $_POST['email'];
	
	if($username && $password && $retypepassword && $email)
	{
	    if ($password == $retypepassword)
		{
			if (strstr($email, "@") && strstr($email, "@"))
			{
				include ("connect.php");
				$query = mysql_query ("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0)
				{
					$password = md5($password);
					
					$register = mysql_query("INSERT INTO users VALUES ('', '$username', '$password' '$email')");
					
					echo "You have been registered.";
					
				}

				else
					echo "That username is taken";
			}
			else
				echo "Not a valid email";
		}
		else
			echo "Passwords did not match";
		
	}
	
	else
	    echo "You did not fill in every field";
	
	
}
else
{
    echo "
	<form action'register.php' method='POST'>
<table width='500'>
<tr>
  <td align='right'>Username:</td>
  <td align='left'><Input type='text' name='username'></td>
</tr>
<tr>
  <td align='right'>Password:</td>
  <td align='left'><Input type='password' name='password'></td>
</tr>
<tr>
  <td align='right'>Retype Password:</td>
  <td align='left'><Input type='password' name='retypepassword'></td>
</tr>
<tr>
  <td align='right'>Email:</td>
  <td align='left'><Input type='text' name='email'></td>
</tr>
<tr>
  <td align='right'></td>
  <td align='left'><Input type='submit' name='button' value='Register'></td>
</tr>
</table></form>
	";
}

?>

</html>
4
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by diafol
0

Use your code like this

<html>
    <?php
     if (isset($_POST['button'])) 
     {
       if ($button)
       {
          // get data
          $username = $_POST['username'];
          $password = $_POST['password'];
          $retypepassword = $_POST['password'];
          $email = $_POST['email'];
     
          if($username && $password && $retypepassword && $email)
          {
              if ($password == $retypepassword)
              {
                 if (strstr($email, "@") && strstr($email, "@"))
                 {
                        include ("connect.php");
                        $query = mysql_query ("SELECT * FROM users WHERE username='$username'");
                        $numrows = mysql_num_rows($query);
                        if ($numrows == 0)
                        {
                             $password = md5($password);
     
                             $register = mysql_query("INSERT INTO users VALUES ('', '$username', '$password' '$email')");
     
                             echo "You have been registered.";
                         }
                         else
                             echo "That username is taken";
                  }
                  else
                       echo "Not a valid email";
             }
             else
                 echo "Passwords did not match";
           }
           else
               echo "You did not fill in every field";
     }
     else
     {  ?>
          <form action'register.php' method='POST'>
                  <table width='500'>
                       <tr>
                           <td align='right'>Username:</td>
                           <td align='left'><Input type='text' name='username'></td>
                       </tr>
                       <tr>
                            <td align='right'>Password:</td>
                            <td align='left'><Input type='password' name='password'></td>
                       </tr>
                       <tr>
                             <td align='right'>Retype Password:</td>
                             <td align='left'><Input type='password' name='retypepassword'></td>
                       </tr>
                       <tr>
                             <td align='right'>Email:</td>
                             <td align='left'><Input type='text' name='email'></td>
                       </tr>
                       <tr>
                             <td align='right'></td>
                             <td align='left'><Input type='submit' name='button' value='Register'></td>
                       </tr>
                  </table>
          </form>
<?php
     } 
  } 
     ?>
     
    </html>
0

I tried the code that six_sic6 posted, it stopped the error, but it shows nothing. It supposed to show username, password, retypepassword and email and register. Srry im new to php

0

its because theres nothing you insert in youre database..
this is youre insert query:

$register = mysql_query("INSERT INTO users VALUES ('', '$username', '$password' '$email')");

you insert into user but where is the column of youre table?
take a look and see the difference.

$register = mysql_query("INSERT INTO users (username,password,email) VALUES ('".$username."','".$password."','".$email."')");

Take note that the username,password,email is the column of youre user table

hope this help

Edited by happytogether: misplace qoute

0

i tried the code

$register = mysql_query("INSERT INTO users (username,password,email) VALUES ('".$username."','".$password."','".$email."')");$register = mysql_query("INSERT INTO users (username,password,email) VALUES ('".$username."','".$password."','".$email."')");

but nothing appears

0

oops i meant

$register = mysql_query("INSERT INTO users (username,password,email) VALUES ('".$username."','".$password."','".$email."')");
0

username,password,email is youre field in youre database?
if not you need to change it according to youre database columns..

0
echo "INSERT INTO users SET username = '$username',password = '$password', email='$email'";

Place this before the sql query. See what it outputs. Copy the output and place it into the SQL (or Query) window in phpMyAdmin. Any errors?

Just check you haven't spelled field passwd or something like that.

0

after i inserted

echo "INSERT INTO users SET username = '$username',password = '$password', email='$email'";

into the script nothing appears

0

echo something after each if/else to see how far you're getting within the code. Where is $button initialised within the script? If you don't have $button, none of it will run.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.