Jump to content

Registration form help


settysantu

Recommended Posts

i have done a registration form but showing some error my problem is its not displaying form in browser

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("registration", $con);

$sql="INSERT INTO person (username, password, e-mail, gender, country, pincode)
VALUES (
$_POST[username],
$_POST[password],
$_POST[e-mail],
$_POST[gender],
$_POST[country],
$_POST[pincode]
)";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con);
?>
<div align="center">
<b>REGISTRATION FORM</b>
<form name="registration form" method="post" action="">
User Name:<input name="username" type="text" /><br /><br />
Passowrd:<input name="password" type="password" /><br /><br />
E-mail Id:<input name="e-mail" type="text" /><br /><br />
Gender:<input name="gender" type="text" /><br /><br />
<br />
Country:<input name="country" type="text" /><br/><br />
Pincode:<input name="pincode" type="text" maxlength="8" />
<br><br />
<input type="submit" name="submit" value="submit">
<input type="reset" value="reset">
</form>
</div>

 

advance thxs

santosh setty

Link to comment
https://forums.phpfreaks.com/topic/56386-registration-form-help/
Share on other sites

I would do two pages one registration.html and submit.php. and when they hit submit on the registration it executes the php code. 

here is the registration page code I modified

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="submit.php">
  <p>User Name:    <input name="username" type="text" />
    <br />
    <br />
Passowrd:<input name="password" type="password" />
<br />
<br />
E-mail Id:<input name="e-mail" type="text" />
<br />
<br />
Gender:<input name="gender" type="text" />
<br />
<br />
<br />
Country:<input name="country" type="text" />
<br/>
<br />
Pincode:<input name="pincode" type="text" maxlength="8" />
</p>
  <p>
    <input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>

i also suggest makin 2 files " register.html " and " register.php " and assign the " register.php " file to the form , so wen u click "submit" it excudes th "register.php" .............. also :

 

- make sure you are connected to mysql . " if ($con) { echo "mysql is connected<b />"; } else { die('couldn't connect to mysql coz:' . mysql_error()); } .

 

- and do the same to your other connections such as the Database and mysql_query . if everything went ok and all are cnnected right , then try the 2 files thing !

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.