Forum Moderators: coopster
i am trying to build a signup page which accepts the details from users and stores it using mysql. The code is as shown below:
<?php
...<login details>
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////////////////////////////
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>(Type a title for your page here)</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?php
if(isset($todo) and $todo=="post"){
$status = "OK";
$msg="";
$userid=serialize($_POST['userid']);
$password=serialize($_POST['password']');
$password2=serialize($_POST['password2']);
$email=serialize($_POST['email']);
$name=serialize($_POST['name']);
$sex=serialize($_POST['sex']);
$agree=serialize($_POST['agree']);
// if userid is less than 3 char then status is not ok
if(!isset($userid) or strlen($userid) <3){
$msg=$msg."User id should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}
if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
$msg=$msg."Userid already exists. Please try another one<BR>";
$status= "NOTOK";}
if ( strlen($password) < 3 ){
$msg=$msg."Password must be more than 3 char legth<BR>";
$status= "NOTOK";}
if ( $password <> $password2 ){
$msg=$msg."Both passwords are not matching<BR>";
$status= "NOTOK";}
if ($agree<>"yes") {
$msg=$msg."You must agree to terms and conditions<BR>";
$status= "NOTOK";}
if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{ // if all validations are passed.
$query=mysql_query("insert into plus_signup(userid,password,email,name,sex) values('$userid','$password','$email','$name','$sex')");
echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up<br><br><a href=login.php>Click here to login</a><br></font>";
}
}
?>
<center>
<br><br><a href='http://www.somesite.com'>PHP SQL HTML free tutorials and scripts</a></center>
</body>
</html>
When i execute this script i get the following error:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\signup-login\signupck.php on line 50
Please tell me where did i go wrong coz i wasn't able to find that out.
[edited by: dreamcatcher at 1:00 pm (utc) on Oct. 27, 2006]
[edit reason] Generalized url. [/edit]
We also have a nice thread on troubleshooting [webmasterworld.com] from our library [webmasterworld.com] that will help you find errors like this is the future.
By the way, Welcome to WebmasterWorld, genious_2k1!
Hope you enjoy your stay :)