topical media & game development
basic-php-12-register.php / php
<?php
session_start();
ob_start();
include "conn.inc.php";
?>
<html>
<head>
<title>Beginning PHP5, Apache and MySQL</title>
</head>
<body>
<?php
if (isset(_POST['submit'] == "Register") {
if (_POST['password'] != "" &&
_POST['last_name'] != "" &&
query = "SELECT username FROM user_info " .
"WHERE username = '" . result = mysql_query(result) != 0) {
?>
<p>
<font color="#FF0000"><b>The Username,
<?php echo _POST['password']; ?>"><br>
Email: <input type="text" name="email"
alue="<?php echo _POST['first_name']; ?>"><br>
Last Name: <input type="text" name="last_name"
value="<?php echo _POST['city']; ?>"><br>
State: <input type="text" name="state"
value="<?php echo _POST['hobbies'])) {
echo " selected";
} ?>>Golfing</option>
<option value="Hunting"<?php
if (in_array("Hunting", _POST['hobbies'])) {
echo " selected";
} ?>>Reading</option>
<option value="Dancing"<?php
if (in_array("Dancing", _POST['hobbies'])) {
echo " selected";
} ?>>Internet</option>
<option value="Flying"<?php
if (in_array("Flying", _POST['hobbies'])) {
echo " selected";
} ?>>Traveling</option>
<option value="Exercising"<?php
if (in_array("Exercising", _POST['hobbies'])) {
echo " selected";
} ?>>Computers</option>
<option value="Other Than Listed"<?php
if (in_array("Other Than Listed", query = "INSERT INTO user_info (username, password, email, " .
"first_name, last_name, city, state, hobbies) " .
"VALUES ('" . _POST['password'] . "')), '" .
_POST['first_name'] .
"', '" . _POST['city'] .
"', '" . _POST['hobbies']) . "');";
query)
or die(mysql_error());
_POST['username'];
_POST['password'];
?>
<p>
Thank you, <?php echo _POST['last_name']; ?> for registering!<br>
<?php
header("Refresh: 5; URL=index.php");
echo "Your registration is complete! " .
"You are being sent to the page you requested!<br>";
echo "(If your browser doesn't support this, " .
"<a href=\"index.php\">click here</a>)";
die();
}
} else {
?>
<p>
<font color="#FF0000"><b>The Username, Password, Email, First Name,
and Last Name fields are required!</b></font>
<form action=<register.php> method="post">
Username: <input type="text" name="username"
value="<?php echo _POST['password']; ?>"><br>
Email: <input type="text" name="email"
value="<?php echo _POST['first_name']; ?>"><br>
Last Name: <input type="text" name="last_name"
value="<?php echo _POST['city']; ?>"><br>
State: <input type="text" name="state"
value="<?php echo _POST['hobbies'])) {
echo " selected";
} ?>>Golfing</option>
<option value="Hunting"<?php
if (in_array("Hunting", _POST['hobbies'])) {
echo " selected";
} ?>>Reading</option>
<option value="Dancing"<?php
if (in_array("Dancing", _POST['hobbies'])) {
echo " selected";
} ?>>Internet</option>
<option value="Flying"<?php
if (in_array("Flying", _POST['hobbies'])) {
echo " selected";
} ?>>Traveling</option>
<option value="Exercising"<?php
if (in_array("Exercising", _POST['hobbies'])) {
echo " selected";
} ?>>Computers</option>
<option value="Other Than Listed"<?php
if (in_array("Other Than Listed",
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.