Jump to content

registration form error


barnes

Recommended Posts

<html>

<body >

 

<table bgcolor="cyan" height="200"width="200" align="center">

<tr align="center"><td><font size="3">UserRegisteration</font></td></tr>

<form name="frmname" action="register1.php" method="post" enctype=""multipart/form-data">

  <tr><td>Username</td><td><input type="text" name="name"></td></tr><br>

<tr><td>password</td><td><input type="password" name="pwd"></td></tr><br>

  <tr><td>E-mail</td><td><input type="text" name="E-mail"></td></tr>

  <tr><td>Confirm E-mail</td><td><input type="text" name="cemail"></td></tr><br>

<tr><td>Address:</td><td><input type="textarea" width="100" height="100" name="address"></td></tr><br>

 

<tr><td>Phone no:</td><td><input type="Text" name="phone"></td></tr><br>

<tr colspan="2" align="center"><td><input type="submit" name="submit" value="submit"></td></tr>

</table>

</body>

</html>

 

 

register1.php

<?php

 

$con = mysql_connect("localhost","root","");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("user", $con);

 

$sql="INSERT INTO user (username,password,E-mail,confirm E-mail,Address,Phone no)

VALUES

('$_POST[username]','$_POST[pwd]','$_POST[E-mail]','$_POST[cemail]','$_POST[address]','$_POST[phone]')";

 

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }

echo "1 record added";

 

mysql_close($con)

?>

 

when i run this script i got the following error:

Parse error: parse error, expecting `']'' in c:\easyphp1-8\www\register1.php on line 13

how to reslove this problem..thanks in advance.

Link to comment
Share on other sites

You can't use "-" in a variable name.  Try "_" (underscore) instead.

 

Additionally, you should write variable accesses within a string like this:

 

$string = "something {$ARRAY['element']} somethingelse";

 

The {} will protect it from being misinterpreted.  The single quotes inside will also help against misinterpretation by php.

Link to comment
Share on other sites

i modified above code.now it's working fine.records are added into database

but following error is getting and e mail is empty.all other fields are added..

 

Notice: Undefined index: email in c:\easyphp1-8\www\register1.php on line 12

1 record added

 

<html>

<body >

 

<table bgcolor="cyan" height="200"width="200" align="center">

<tr align="center"><td><font size="3">UserRegisteration</font></td></tr>

<form name="frmname" action="register1.php" method="post" enctype=""multipart/form-data">

<tr><td>Username</td><td><input type="text" name="name"></td></tr><br>

<tr><td>password</td><td><input type="password" name="pwd"></td></tr><br>

<tr><td>E-mail</td><td><input type="text" name="email"></td></tr>

<tr><td>Confirm E-mail</td><td><input type="text" name="cemail"></td></tr><br>

<tr><td>Address:</td><td><input type="textarea" width="100" height="100" name="address"></td></tr><br>

 

<tr><td>Phone no:</td><td><input type="Text" name="phone"></td></tr><br>

<tr colspan="2" align="center"><td><input type="submit" name="submit" value="submit"></td></tr>

</table>

</body>

</html>

 

 

 

</form>

</table>

 

register1.php

<?php

 

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("user", $con);

$username=mysql_real_escape_string($_POST['name']);

$pwd=mysql_real_escape_string($_POST['pwd']);

$email=mysql_real_escape_string($_POST['email']);

$cemail=mysql_real_escape_string($_POST['cemail']);

$add=mysql_real_escape_string($_POST['address']);

$phone=mysql_real_escape_string($_POST['phone']);

 

$sql="INSERT INTO user (username,password,email,confirmemail,Address,Phoneno)

VALUES

('{$username','$pwd','$email','$cemail','$add','$phone')";

 

if (!mysql_query($sql,$con))

{

die('Error: ' . mysql_error());

}

echo "1 record added";

 

mysql_close($con)

?>

Link to comment
Share on other sites

i modified above code.now it's working fine.records are added into database

but following error is getting and e mail is empty.all other fields are added..

 

Notice: Undefined index: email in c:\easyphp1-8\www\register1.php on line 12

1 record added

 

<html>

<body >

 

<table bgcolor="cyan" height="200"width="200" align="center">

<tr align="center"><td><font size="3">UserRegisteration</font></td></tr>

<form name="frmname" action="register1.php" method="post" enctype=""multipart/form-data">

<tr><td>Username</td><td><input type="text" name="name"></td></tr><br>

<tr><td>password</td><td><input type="password" name="pwd"></td></tr><br>

<tr><td>E-mail</td><td><input type="text" name="email"></td></tr>

<tr><td>Confirm E-mail</td><td><input type="text" name="cemail"></td></tr><br>

<tr><td>Address:</td><td><input type="textarea" width="100" height="100" name="address"></td></tr><br>

 

<tr><td>Phone no:</td><td><input type="Text" name="phone"></td></tr><br>

<tr colspan="2" align="center"><td><input type="submit" name="submit" value="submit"></td></tr>

</table>

</body>

</html>

 

 

 

</form>

</table>

 

register1.php

<?php

 

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("user", $con);

$username=mysql_real_escape_string($_POST['name']);

$pwd=mysql_real_escape_string($_POST['pwd']);

$email=mysql_real_escape_string($_POST['email']);

$cemail=mysql_real_escape_string($_POST['cemail']);

$add=mysql_real_escape_string($_POST['address']);

$phone=mysql_real_escape_string($_POST['phone']);

 

$sql="INSERT INTO user (username,password,email,confirmemail,Address,Phoneno)

VALUES

('{$username}','{$pwd}','{$email}','{$cemail}','{$add}','{$phone}')";

 

if (!mysql_query($sql,$con))

{

die('Error: ' . mysql_error());

}

echo "1 record added";

 

mysql_close($con)

?>

Link to comment
Share on other sites

i changed to $sql="INSERT INTO user (Username,password,email,Confirmemail,Address,Phoneno)

but not working..i think this not a problem..all feilds are added in the database,but only email feild is problem.it's empty and getting following error.

Notice: Undefined index: email in c:\easyphp1-8\www\register1.php on line 12

1 record added

Link to comment
Share on other sites

no.i copied these fields from database.no difference.but this stmt above the code error_reporting(E_ALL ^ E_NOTICE);.notice is not displayed but email feild is empty in database.

Username

password

email

Confirmemail

Address

Phoneno

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.