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>
Member Avatar for diafol

This usually means you have different number of { and } in the code. Count 'em up.

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>

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

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

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

oops i meant

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

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

username,password,email is in my database

Member Avatar for diafol
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.

after i inserted

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

into the script nothing appears

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.