Registration Page written in PHP

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 5765 Views - Last Post: 18 February 2010 - 08:37 PM Rate Topic: -----

#1 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Registration Page written in PHP

Posted 26 January 2010 - 10:06 PM

well, this is kinda embarrassing since I'm working on a college project, and right now I'm stuck at the registration page. Here's the code and the error:

Registration Page

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Online Music Player Registration Site</title><style type="text/css">
.prompt{color: blue; font-family:Arial; font-size:medium}
</style></head>
<body>
<p><big style="font-weight: bold;">
  REGISTER TO THIS SITE</big><br>
</p>
<p><br>
  Register to this site in order to gain the full benefits this site offers.<br>
</p>
<form method="post" action="form.php">
  <table width="100%" border="0" cellpadding="0" cellspacing="1">
		<tr>
	  <td width="10%" valign="top">Username</td>

	  <td width="48%"><input type="text" name="username" /> <br /> </font></td>
	</tr>
	<tr>
	  <td>Password</td>
	  <td><input type="password" name="password" /><br>
		  </tr>
		<tr>
	  <td colspan="2"><hr size="1" /></td>
	</tr>
			<tr>
	  <td>Email</td>
	  <td><input type="text" name="email" />	  <br/><font color="red" size="2">(E-mail is important so that your registration can be verified) </font></td>
	</tr>
	<tr>
	<td><p>Type of user</p></td>
	<td>	
	<input type="radio" name="user" value= "normal user" /> Normal user
	<input type="radio" name="user" value= 	"musician" /> Musician
	</td>
	</tr>
	<tr>
	<td><p>Gender</p></td>
	<td>
	<input type="radio" name="gender" value="female" />Female
	<input type="radio" name="gender" value="male" />	Male	</td>
	</tr>
	<tr>
	  <td><p> </p></td>
	  <td><p><br />
		  <input type="submit" name="Submit" value="Register" class="funcbutton" />
	  </p></td>
	</tr>
  </table>
	<input type="hidden" name="ref" value="" />
</form>



form.php
<?php
$username = htmlspecialchars($_POST['username']);
if (preg_match("/\s/",$text))
{
	die("do not use spaces, tabs or newlines in your username");
}
$email = htmlspecialchars($_POST['email']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
	die("Invalid E-mail address");
}

$Password = htmlspecialchars($_POST['Password']);
if (preg_match("/\s/",$text))
{
	die("do not use spaces, tabs or newlines in your password");
}
?>

<html>
<body>

Your name is: <?php echo $username; ?><br />
Your e-mail: <?php echo $email; ?><br />
<br />

</body>
</html>

<?php
function check_input($data)
{
	$data = trim($data);
	$data = stripslashes($data);
	$data = htmlspecialchars($data);
	if ($problem && strlen($data) == 0)
	{
		die($problem);
	}
	return $data;
}

function show_error($anyError)
{
	?>
	<html>
	<body>
	
	<b>Please correct the following errors:</b><br />
	<?php echo $myError; ?>

	</body>
	</html>
<?php
exit();
}
?>


The message I got was:

Quote

Notice: Undefined variable: text in C:\wamp\www\mplayer\form.php on line 3

Notice: Undefined index: Password in C:\wamp\www\mplayer\form.php on line 13

Notice: Undefined variable: text in C:\wamp\www\mplayer\form.php on line 14
Your name is: fuser
Your e-mail: hadri90@gmail.com


and another function I was working on is a date of birth selection option, since my supervisor suggested that I include it in my page to filter out users who are below 15 years old.

<html xmlns="http://www.w3.org/1999/xhtml">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?> ">
<select name="day"><?php 
for ($i = 1; $i <= 31; i++) {
	echo "<option value=\"$i\">$i</option>\n";
}
?></select>

<select name="month"><?php
for ($i = 1; $i <= 12; i++) {
	$monthname = date('F', mktime(12, 0, 0, $i, 1, 1930));
	echo "<option value=\"$i\">$monthname</option";
}
?></select>

<select name="year"><?php
for ($i = 1930; $i = 2010; i++) {
	echo "<option value=\"$i\">$i</option>";
}
?></select>
</form>
</html>



the message I got for this one is:

Quote

Parse error: parse error, expecting `')'' in C:\wamp\www\dateselection.php on line 4


and another thing, does anyone know how I can implement the date selection code into the registration form?

Is This A Good Question/Topic? 0
  • +

Replies To: Registration Page written in PHP

#2 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 26 January 2010 - 10:15 PM

one thing, I just noticed that in form.php, I forgot to change the $text to username, as well as for the other variables in the form. I'm going to fix it and get back with the results
Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2927
  • View blog
  • Posts: 10,114
  • Joined: 08-August 08

Re: Registration Page written in PHP

Posted 27 January 2010 - 06:09 AM

Two suggestions:

1) If you're going to code in php, then code in php. It looks like you've spent more time worrying about your html than your php and that's a good way to confuse yourself. Instead, write the php and only add html when you're confident that the php works.

2) Don't use tables for formatting! Use CSS. See this link: http://www.csszengarden.com/
Was This Post Helpful? 0
  • +
  • -

#4 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 27 January 2010 - 11:29 AM

The problem is fixed, although now I need to some help in making the days according to the appropriate months, and also, my supervisor wants me to set an age limit for those signing up for this site (preferably 15), by deducting the date of birth provided by the user and the date the user signs up, but I'm pretty stuck atm.

anyone knows how to do this?
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2927
  • View blog
  • Posts: 10,114
  • Joined: 08-August 08

Re: Registration Page written in PHP

Posted 27 January 2010 - 02:32 PM

http://php.net/manua...nction.date.php

or more generally, http://php.net
Was This Post Helpful? 0
  • +
  • -

#6 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 04 February 2010 - 12:43 AM

my date selection code seems to be working properly now, as it can differentiate between leap years, but now I can't figure out how to make it to compare with today's date. most of the solutions offered seems to store the date directly into the PHP file, and they don't support leap years. What I want to do is to get the user to select the date, and then the file will compare it with today's date, and determine whether the user is at least 13. If so, the user can then proceed. Note that I use a drop-down menu for the date selection as I want to include it into the registration page.

<?php
  if (isset($_POST['month']) && is_numeric($_POST['month']) &&
    ((int)$_POST['month'] >= 1 && (int)$_POST['month'] <= 12)) {
    $month = (int)$_POST['month'];
  } else {
    $month = date('n');
  }
  if (isset($_POST['year']) && is_numeric($_POST['year']) &&
    ((int)$_POST['year'] >= 1971 && (int)$_POST['year'] <= 2010)) {
    $year = (int)$_POST['year'];
  } else {
  $year = date('Y');
  }
?>

</p>
  <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
    <select name="day"><?php
      $maxdays = date('t', mktime(12, 0, 0, $month, 1, $year));
      for ($i = 1; $i <= $maxdays; $i++) {
        if (isset($_POST['day']) && $_POST['day'] == $i) {
          $sel = ' selected';
        } elseif ($i == date('j')) {
          $sel = ' selected';
        } else {
          $sel = '';
        }
        echo "<option value=\"$i\"$sel>$i</option>\n";
      }
    ?></select>
    <select name="month" onchange="this.form.submit();"><?php
      for ($i = 1; $i <= 12; $i++) {
        if ($month == $i) {
          $sel = ' selected';
        } else {
          $sel = '';
        }
        $monthname = date('F', mktime(12, 0, 0, $i, 1, 1971));
        echo "<option value=\"$i\"$sel>$monthname</option>\n";
      }
    ?></select>
    <select name="year" onchange="this.form.submit();"><?php
      for ($i = 1971; $i <= 2010; $i++) {
        if ($year == $i) {
          $sel = ' selected';
        } else {
          $sel = '';
        }
        echo "<option value=\"$i\"$sel>$i</option>\n";
      }
      ?></select>



secondly, I tried attaching the code to the registration page using both include() and require() but I seem to be unable to make it display. (Note that the code is kept in a separate page, in the same directory)
Was This Post Helpful? 0
  • +
  • -

#7 Auzzie  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 43
  • View blog
  • Posts: 573
  • Joined: 20-January 09

Re: Registration Page written in PHP

Posted 04 February 2010 - 01:38 AM

Well first off i cannot see an include or require call in the code you just posted :) secondly if you are trying to compare the user's DOB with today's date then why not just use the date() function to generate today's date?
Was This Post Helpful? 0
  • +
  • -

#8 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 05 February 2010 - 12:30 AM

ok, after much thinking last night I've decided to ditch the dob code since it's causing me unncessary trouble. Right now I'm working on the registration page, and this error simply stumped me.

I assume there's an error in my syntax, but I can't seem to figure it out.

Registration Page:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Online Music Player Registration Site</title><style type="text/css">
.prompt{color: blue; font-family:Arial; font-size:medium}
</style></head>
<body>
<p><big style="font-weight: bold;">
  REGISTER TO THIS SITE</big><br>
</p>
<p><br>
  Register to this site in order to gain the full benefits this site offers.<br>
</p>
<form method="post" action="form.php">
  <table width="100%" border="0" cellpadding="0" cellspacing="1">
    	<tr>
      <td width="10%" valign="top">Username</td>

      <td width="48%"><input type="text" name="username" /> <br /> </font></td>
    </tr>
	<tr>
      <td>Password</td>
      <td><input type="password" name="password" /><br>
	      </tr>
		<tr>
	  <td colspan="2"><hr size="1" /></td>
    </tr>
			<tr>
      <td>Email</td>
	  <td><input type="text" name="email" />	  <br/><font color="red" size="2">(E-mail is important so that your registration can be verified) </font></td>
    </tr>
	<tr>
	<td><p>Type of user</p></td>
	<td>	
	<input type="radio" name="user" value= "normal user" /> Normal user
    <input type="radio" name="user" value= 	"musician" /> Musician
	</td>
	</tr>
	<tr>
	<td><p>Gender</p></td>
	<td>
	<input type="radio" name="gender" value="female" />Female
	<input type="radio" name="gender" value="male" />	Male	</td>
	</tr>
    <tr>
      <td><p>
        <input type="submit" name="Submit" id="Submit" value="Submit">
        <br />
      </p></td>
    </tr>
  </table>
    <input type="hidden" name="ref" value="" />
</form>




[edit]
form.php

<?php
$username = htmlspecialchars($_POST['user_name']);
if (preg_match("/\s/",$username))
{
	die("do not use spaces, tabs or newlines in your username");
}
$email = htmlspecialchars($_POST['user_email']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
die("Invalid E-mail address");
}
$Password = htmlspecialchars($_POST['user_password']);
if (preg_match("/\s/",$Password))
{
	die("do not use spaces, tabs or newlines in your password");
}
?>

<html>
<body>

Your name is: <?php echo $username; ?><br />
Your password is: <?php echo $Password; ?><br />
Your e-mail: <?= $email ?><br />

<?php echo "Please remember your details for future registration"; ?><br />
<br />

</body>
</html>

<?php
function check_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
	if ($problem && strlen($data) == 0)
	{
		die($problem);
	}
    return $data;
}

function show_error($anyError)
{
	?>
	<html>
	<body>

		<b>Please correct the following errors:</b><br />
		<?php echo $myError; ?>

	</body>
	</html>
<?php
exit();
}
?>

<?php

$connect = mysql_connect("localhost", "root") or die ("connection could not be established.");

mysql_select_db("users");

$insert = "INSERT INTO user(user_name, user_password, user_email, user_type, user_gender)" .  
"VALUES ('{$_POST['user_name']}', '{$_POST['password']}', '{$_POST['user_email']}', '{$_POST['user_type']}', '{$_POST['user_gender']}')";

$results = mysql_query($insert) or die (mysql_error());

?>



[/edit]

create user table:

createuser.php

<?php

$connect = mysql_connect("localhost", "fuser", "projectpass") or die("Could not establish connection");

$create = mysql_query("CREATE DATABASE IF NOT EXISTS users") or die (mysql_error());

mysql_select_db("users");

$user = "CREATE TABLE user(user_id int(15) NOT NULL auto_increment,
user_name varchar(255) NOT NULL,
user_password varchar(255) NOT NULL,
user_email varchar(255) NOT NULL,
user_type varchar(255) NOT NULL,
user_gender varchar(255) NOT NULL,
PRIMARY KEY (user_id),
KEY user_type(user_type, user_gender))";

$results = mysql_query($user) or die (mysql_error());

$usertype = "CREATE TABLE usertype 
(usertype_id tinyint(2) NOT NULL auto_increment,
usertype_type varchar(255) NOT NULL,
PRIMARY KEY(usertype_id))";

$results = mysql_query($usertype) or die (mysql_error());

$gender = "CREATE TABLE gender
(gender_id int(15) NOT NULL auto_increment,
gender_type varchar(255) NOT NULL,
PRIMARY KEY(gender_id))";

$results = mysql_query($gender) or die (mysql_error());

echo "Database Created";

?>


and the user table:

userdata.php

<?php

$connect = mysql_connect("localhost", "fuser", "projectpass") or die("connection could not be established");

mysql_select_db("users");

$insert = "INSERT INTO user(user_id, user_name, user_password, user_email, user_type, user_gender)" . 
"VALUES (1, 'User A', 'abcdef', 'zzyx@mail.com', 1, 1), " .
"(2, 'User B', 'abc123', 'mail@mail.com', 1, 2), " .
"(3, 'User C', 'zxcvbn', '1234@mail.com', 2, 1), " .
"(4, 'User D', 'qwerty', 'abcd@mail.com', 2, 2), " .
"(5, 'User E', '123456', 'xkcd@mail.com', 3, 2) " ;

$results = mysql_query($insert) or die (mysql_error());

$type = "INSERT INTO usertype(usertype_id, usertype_type) " .
" VALUES (1, 'Normal User'), " . 
" (2, 'Musician'), " . 
" (3, 'Administrator') ";

$results = mysql_query($type) or die (mysql_error());

$gender = "INSERT INTO gender(gender_id, gender_type) " . 
" VALUES (1, 'Female'), " . 
" (2, 'Male') "; 

$results = mysql_query($gender) or die (mysql_error());

?>


I should note that my login page works fine though..

login.php

<html>
<head>
<title>Login Page</title>
<title>Online Music Player Login Page</title><style type="text/css">
.prompt{color: blue; font-family:Arial; font-size:medium}
</style></head>
<form method="post" action="checkLogin.php">
  <table width="100%" border="0" cellpadding="0" cellspacing="1">
    	<tr>
      <td width="10%" valign="top">Username</td>

      <td width="48%"><input type="text" name="username" /> <br /> </font></td>
    </tr>
	<tr>
      <td>Password</td>
      <td><input type="password" name="password" /><br>
	      </tr>
		<tr>
	  <td colspan="2"><hr size="1" /></td>
    </tr>
	  <tr>
      <td><p>
        <input type="submit" name="Submit" id="Submit" value="Submit">
        <br />
      </p></td>
    </tr>
  </table>
    <input type="hidden" name="ref" value="" />
</form>
</html>


checkLogin.php

<?php
// checkLogin.php

session_start(); // Start a new session
require('conn.php'); // Holds all of our database connection information

// Get the data passed from the form
$username = $_POST['username'];
$password = $_POST['password'];

// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);

$sql = "select * from user where user_name = '$username' and user_password = '$password'";
$result = mysql_query($sql) or die ( mysql_error() );

$count = 0;

while ($line = mysql_fetch_assoc($result)) {
	 $count++;
}

if ($count == 1) {
	 $_SESSION['loggedIn'] = "true";
	 echo "welcome";
} else {
	 $_SESSION['loggedIn'] = "false";
	 echo "sorry, try again.";
}

?>


the funny thing is that the error now is that all the e-mail addresses I've inputted into the e-mail field are considered invalid.. o_O

This post has been edited by hdr: 05 February 2010 - 02:48 AM

Was This Post Helpful? 0
  • +
  • -

#9 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5246
  • View blog
  • Posts: 27,062
  • Joined: 10-May 07

Re: Registration Page written in PHP

Posted 05 February 2010 - 02:35 AM

View Posthdr, on 05 February 2010 - 01:30 AM, said:

Parse error: syntax error, unexpected $end in G:\xampplite\htdocs\mplayer\form.php on line 66


What's with this line?

Quote

Your e-mail: <?= $email ?><br />


Try replacing it with the following :

Your e-mail: <?php echo $email; ?><br />


Also, you have no closing bracket for your function :

Quote

function show_error($anyError) {
?>

Was This Post Helpful? 0
  • +
  • -

#10 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 05 February 2010 - 03:21 AM

the previous post was a bit too long, so I hope no one is offended by the fact I've decided to make a new post.

I think I've fixed the form code now, so it now looks like this:

<?php
$username = htmlspecialchars($_POST['user_name']);
if (preg_match("/\s/",$username))
{
	die("do not use spaces, tabs or newlines in your username");
}
$email = htmlspecialchars($_POST['user_email']);
if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
die("Invalid E-mail address");
}
$Password = htmlspecialchars($_POST['user_password']);
if (preg_match("/\s/",$Password))
{
	die("do not use spaces, tabs or newlines in your password");
}
?>

<html>
<body>

Your name is: <?php echo $username; ?><br />
Your password is: <?php echo $Password; ?><br />
Your e-mail: <?php echo $email?><br />

<?php echo "Please remember your details for future registration"; ?><br />
<br />

</body>
</html>

<?php
function check_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
	if ($problem && strlen($data) == 0)
	{
		die($problem);
	}
    return $data;
}

function show_error($anyError)
{
	?>
	<html>
	<body>

		<b>Please correct the following errors:</b><br />
		<?php echo $myError; ?>

	</body>
	</html>
<?php
exit();
}
?>

<?php

$connect = mysql_connect("localhost", "root") or die ("connection could not be established.");

mysql_select_db("users");

$insert = "INSERT INTO user(user_name, user_password, user_email, user_type, user_gender)" .  
"VALUES ('{$_POST['user_name']}', '{$_POST['password']}', '{$_POST['user_email']}', '{$_POST['user_type']}', '{$_POST['user_gender']}')";

$results = mysql_query($insert) or die (mysql_error());

?>



well, the issue now is:

Posted Image

results in:


Posted Image

I'm pretty sure I've screwed the code up somewhere, just not sure which one.

This post has been edited by hdr: 05 February 2010 - 03:31 AM

Was This Post Helpful? 0
  • +
  • -

#11 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5246
  • View blog
  • Posts: 27,062
  • Joined: 10-May 07

Re: Registration Page written in PHP

Posted 05 February 2010 - 03:24 AM

So remind me why we're helping you if you are just ignoring the errors we point out?
Was This Post Helpful? 0
  • +
  • -

#12 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 05 February 2010 - 03:34 AM

I've already corrected the errors pointed out. the only problem right now is unrelated to the fixes I've applied. it connects to the database, updates it and shows the changes, but the only field visible is the user password field. others just show up blank.

This post has been edited by hdr: 05 February 2010 - 03:38 AM

Was This Post Helpful? 0
  • +
  • -

#13 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5246
  • View blog
  • Posts: 27,062
  • Joined: 10-May 07

Re: Registration Page written in PHP

Posted 05 February 2010 - 03:42 AM

You never ever ever want to put POST values straight into your sql. Verify that data exists!

if($_POST['user_email']!="") $email=$_POST['user_email'];
else die("Email blank");
if($_POST['user_name']!="") $user=$_POST['user_name'];
else die("Username blank");
if($_POST['password']!="") $pass=$_POST['password'];
else die("Password blank");
if($_POST['user_type']!="") $type=$_POST['user_type'];
else die("Type blank");
if($_POST['user_gender']!="") $gend=$_POST['user_gender'];
else die("Gender blank");

mysql_select_db("users");

$insert = "INSERT INTO user(user_name, user_password, user_email, user_type, user_gender)" .  
"VALUES ('$user', '$pass', '$email', '$type', '$gend')";

$results = mysql_query($insert) or die (mysql_error());
if(!$results) {
  echo "The following SQL failed <hr>$insert";
}



Also use the following to debug your variables :

Your name is: <?php 
  if($username!="") echo $username; 
  else echo "Username not set";
?><br />
Your password is: <?php echo $Password; ?><br />
Your e-mail: <?php 
  if($email!="") echo $email;
  else echo "Email not set";
?><br />

Was This Post Helpful? 0
  • +
  • -

#14 hdr  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 151
  • Joined: 15-December 08

Re: Registration Page written in PHP

Posted 05 February 2010 - 04:17 AM

<?php
$username = htmlspecialchars($_POST['user_name']);
if (preg_match("/\s/",$username))
{
	die("do not use spaces, tabs or newlines in your username");
}
$email = htmlspecialchars($_POST['user_email']);
if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
die("Invalid E-mail address");
}
$Password = htmlspecialchars($_POST['user_password']);
if (preg_match("/\s/",$Password))
{
	die("do not use spaces, tabs or newlines in your password");
}
?>

<html>
<body>

Your name is: <?php 
  if($username!="") echo $username; 
  else echo "Username not set";
?><br />
Your password is: <?php echo $Password; ?><br />
Your e-mail: <?php 
  if($email!="") echo $email;
  else echo "Email not set";
?><br />
<?php echo "Please remember your details for future registration"; ?><br />
<br />

</body>
</html>

<?php
function check_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
	if ($problem && strlen($data) == 0)
	{
		die($problem);
	}
    return $data;
}

function show_error($anyError)
{
	?>
	<html>
	<body>

		<b>Please correct the following errors:</b><br />
		<?php echo $myError; ?>

	</body>
	</html>
<?php
exit();
}
?>

<?php

$connect = mysql_connect("localhost", "root") or die ("connection could not be established.");

if($_POST['user_email']!="") $email=$_POST['user_email'];
else die("Email blank");
if($_POST['user_name']!="") $user=$_POST['user_name'];
else die("Username blank");
if($_POST['password']!="") $Password=$_POST['user_password'];
else die("Password blank");
if($_POST['user_type']!="") $type=$_POST['user_type'];
else die("Type blank");
if($_POST['user_gender']!="") $gender=$_POST['user_gender'];
else die("Gender blank");

mysql_select_db("users");

$insert = "INSERT INTO user(user_name, user_password, user_email, user_type, user_gender)" .  
"VALUES ('$username', '$Password', '$email', '$type', '$gender')";

$results = mysql_query($insert) or die (mysql_error());
if(!$results) {
  echo "The following SQL failed <hr>$insert";
}

?>



did I put it in correctly? cause I the only results I get is:

Your name is: Username not set
Your password is:
Your e-mail: Email not set
Please remember your details for future registration

Email blank
Was This Post Helpful? 0
  • +
  • -

#15 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5246
  • View blog
  • Posts: 27,062
  • Joined: 10-May 07

Re: Registration Page written in PHP

Posted 05 February 2010 - 12:10 PM

You are pulling Post with this $_POST['user_name'], but you pass it form the form with this name="username".

Syntax.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3