Jump to content

form validation errors


lee2010

Recommended Posts

hi all, i have a register page with some basic validation but its throwing out this error:

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\process_r.php on line 84

 

heres my code:

 

register.php

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!--
Author: Reality Software
Website: http://www.realitysoftware.ca
Note: This is a free template released under the Creative Commons Attribution 3.0 license, 
which means you can use it in any way you want provided you keep the link to the author intact.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">

$(document).ready(function(){
  $("#username_input").keyup(function(){
    txt=$("#username_input").val();
    $.post("check.php",{username:txt},function(result){
      $("#feedback").html(result);
    });
  });
});

</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.auto-style2 {
font-size: 25px;
}
.auto-style3 {
font-size: small;
}
</style>
</head>
<body>

<div id="container">
<!-- header -->
    <div id="header">
    	<div id="logo"><a href="#"><span class="orange">SouthWest</span> LAN's</a></div>
        <div id="menu">
        	<ul>
            <li><a href="index.php">Home</a></li>
            <li><a href="events.php">Events</a></li>
            <li><a href="account.php">My Account</a></li>
            <li><a href="forum.php">Forums</a></li>
            <li><a href="faq.php">FAQ</a></li>
            </ul>
        </div>
    </div>
    <!--end header -->
    <!-- main -->
    <div id="main">
        <div id="content">
        <div id="head_image">
        	<div id="slogan"><strong><span class="auto-style2">Organising LAN Parties in the SouthWest</span></strong><br /></div>
            <div id="under_slogan_text"></div>
        </div>
        <div id="text">
          <h1>Registration:</h1>
           <br />
          
           <p class="auto-style3">Don't forget your login details as you will need them everytime you wish to login.</p>
	   
<form name="register" method="post" action="process_r.php">
<table border="0" width="225" align="center">
    <tr>
        <td width="219" bgcolor="#999999">
            <p align="center"><font color="white"><span style="font-size:12pt;">
		All fields are required</span></font></p>
        </td>
    </tr>
    <tr>
        <td width="219">
            <table border="0" width="282" align="center">
                    <tr>
                        <td width="116"><span style="font-size:10pt;">Username:</span></td>
                        <td width="156"><input type="text" id="username_input" name="username" maxlength="100" value="<?php echo $username; ?>"></td>
                    </tr>
				<tr>
                        <td width="116"><span style="font-size:10pt;"></span></td>
                        <td width="116"><div id="feedback"></div></td>
                    </tr>
                    <tr>
                        <td width="116"><span style="font-size:10pt;">Email:</span></td>
                        <td width="156"><input type="text" name="email" maxlength="100" value="<?php echo $email; ?>"></td>
                    </tr>
                <tr>
                    <td width="116"><span style="font-size:10pt;">Password</span></td>
                    <td width="156"><input type="password" name="password"></td>
                </tr>
                <tr>
                    <td width="116"><span style="font-size:10pt;">Confirm Password:</span></td>
                    <td width="156"><input type="password" name="c_password"></td>
                </tr>
                <tr>
                    <td width="116"> </td>
                        <td width="156">
                            <p align="right"><input type="submit" name="register" value="Register"></p>
                        </td>
                </tr>
            </table>
        </td>
    </tr>
    
</table>
</form>

                       </div>
              </div>
       </div>
    </div>
    <!-- end main -->
    <!-- footer -->
    <div id="footer">
    <div id="left_footer"><a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a><br />© Copyright 2008 Clicker design
    
  

    </div>
    <div id="right_footer">

<!-- Please do not change or delete this link. Read the license! Thanks. :-) -->
Design by <a href="http://www.realitysoftware.ca" title="Website Design">Reality Software</a>

    </div>
    </div>
    <!-- end footer -->

</body>
</html>

 

process_r.php

 

<?PHP

//Database Information

$dbhost = "localhost";
$dbname = "lee";
$dbuser = "lee";
$dbpass = "leecopter";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

//Clean data
$_POST = array_map('strip_tags', $_POST);
$_POST = array_map('mysql_real_escape_string', $_POST);
    
$username = $_POST['username'];
$email = $_POST['email'];    
$password = md5($_POST['password']);
$c_password = $_POST['c_password'];
$errorstring = "";


if(!$username){
	$errorstring = $errorstring."Username<br>";
	}
if(!$email){
	$errorstring = $errorstring."Email<br>";
	}
if(!$password){
	$errorstring = $errorstring."Password<br>";
	}
if(!$c_password){
	$errorstring = $errorstring."Confirm Password<br>";
	}


if ($errorstring!=""){
	echo "Please full out the following fields:<br>$errorstring";
	}

else{

//Check to see if the username already exists

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo 'Im sorry but the username you specified has already been taken.  Please pick another one.';
    unset($username);
    include 'register.php';
    exit();
}

$query = "INSERT INTO users (username, email, password)
VALUES('$username', '$email', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
include 'thank-you.php'


// mail user their information

//$yoursite = ‘www.blahblah.com’;
//$webmaster = ‘yourname’;
//$youremail = ‘youremail’;
    
//$subject = "You have successfully registered at $yoursite...";
//$message = "Dear $name, you are now registered at our web site.  
  //  To login, simply go to our web page and enter in the following details in the login form:
   // Username: $username
   // Password: $password
    
  //  Please print this information out and store it for future reference.
    
   // Thanks,
  //  $webmaster";
    
//mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
}
?>

 

pretty sure the problem is within the process_r.php file

Link to comment
Share on other sites

Gotta read those error messages, man.  It says it's on line 84 in process_r.php where there was an unexpected "}".  Generally, when you get an unexpected error, it means you forgot a semicolon in the line before it.

 

include 'thank-you.php';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.