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 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
and another thing, does anyone know how I can implement the date selection code into the registration form?

New Topic/Question
Reply




MultiQuote







|