Thanks for the linkage 🙂
I'm at the stage now, where I have created a (Very primitive) registration page and I am trying to get it to write to the database. Having a little difficulty with that. It's not giving an error message, it's kida like it's not doing anything at all. must get good at proof reading own code
Here's what me has so far
<html>
<head>
<title>Registration</title>
</head>
<body>
<table height="100%" width="100%">
<tr>
<td valign="top" bgcolor="#000000" width="20%">
<font color="#FFFFFF">
<p align="left">
<? include("menutable.php"); ?>
</p>
</td>
<td valign="top">
<img src="http://www.webfriends.biz/images/banner2.gif" alt="WebFriends!" border="0" >
<form action="registering.php" method="post">
<select name="usertype"><br />
<option value="customer">Register as a Customer</option>
<option value="webfiends">Register as a WebFriend</option>
<option value="both">Register as both</option>
</select><br />
Enter your prefered username: <input type="text" name="username" /><br />
Enter your first name: <input type="text" name="firstname" /><br />
Enter your surname: <input type="text" name="surname" /><br />
Enter your prefered password: <input type="password" name="password" /><br />
Confirm password: <input type="password" name="passconfirm"><br />
Enter your email address: <input type="text" name="email"><br />
Confirm email: <input type="text" name="emailconfirm"><br />
Enter your Date of Birth: <input type="date" name ="dob"><br />
Enter the first line of your address: <input type="text" name="alone"><br />
Enter the second line of your address: <input type="text" name="altwo"><br />
Enter the third line of your address: <input type="text" name="althree"><br />
Enter your county:
<select name="location"><br />
<option value="Birmingham">Birmingham</option>
<option value="Manchester">Manchester</option>
<option value="Leeds">Leeds</option>
<option value="London">London</option>
<option value="North Yorkshire">North Yorkshire</option>
</select><br />
Enter your postcode: <input type="text" name="postcode"><br />
Enter your daytime telephone number: <input type="text" name="daytime"><br />
Enter your evening telephone number: <input type="text" name="evening"><br />
Enter your mobile number: <input type="text" name="mobile"><br />
<input type="submit" value="Register!"/>
</form>
</p>
</td>
</tr>
</table>
</body>
</head>
<html>
<head>
<title>Register!</title>
</head>
<body>
<table height="100%" width="100%">
<tr>
<td valign="top" bgcolor="#000000" width="20%">
<font color="#FFFFFF">
<p align="left">
<? include("menutable.php"); ?>
</p>
</td>
<td valign="top">
<img src="http://www.webfriends.biz/images/banner2.gif" alt="WebFriends!" border="0" >
<?php
$dbcnx = @mysql_connect('info', 'info', 'info');
if (!$dbcnx) {
echo 'Unable to connect to the ' .
'database server at this time.' ;
exit();
}
// Select the database
if (!@mysql_select_db('info')) {
exit('Unable to locate the ' .
'database at this time.');
}
// Write to the fields
$usertype= addslashes(htmlentities($_POST['usertype']));
$username= addslashes(htmlentities($_POST['username']));
$firstname= addslashes(htmlentities($_POST['firstname']));
$surename= addslashes(htmlentities($_POST['surname']));
$password= addslashes(htmlentities($_POST['password']));
$passconfirm= addslashes(htmlentities($_POST['passconfirm']));
$email= addslashes(htmlentities($_POST['email']));
$emailconfirm= addslashes(htmlentities($_POST['emailcomfirm']));
$dob= addslashes(htmlentities($_POST['dob']));
$alone= addslashes(htmlentities($_POST['alone']));
$altwo= addslashes(htmlentities($_POST['altwo']));
$althree= addslashes(htmlentities($_POST['althree']));
$location= addslashes(htmlentities($_POST['location']));
$postcode= addslashes(htmlentities($_POST['postcode']));
$daytime= addslashes(htmlentities($_POST['daytime']));
$evening= addslashes(htmlentities($_POST['evening']));
$mobile= addslashes(htmlentities($_POST['mobile']));
if ( $usertype == "webfriends" ) {
$sql = "INSERT INTO webfriends (username, firstname, surname, password, alone, altwo, althree, county, country, daytime, evening, mobile, dob, email, postcode) VALUES ('$username', '$firstname', '$surname', '$password', '$alone', '$altwo', '$althree', '$county', '$country', '$alone', '$daytime', '$evening', '$mobile', '$dob', '$email')";
if (@mysql_query($sql)) {
echo 'registration sucsefull!';
}
}
else if ( $usertype == "customer" ) {
$sql = "INSERT INTO customer (username, firstname, surname, password, alone, altwo, althree, county, country, daytime, evening, mobile, dob, email, postcode) VALUES ('$username', '$firstname', '$surname', '$password', '$alone', '$altwo', '$althree', '$county', '$country', '$alone', '$daytime', '$evening', '$mobile', '$dob', '$email')";
if (@mysql_query($sql)) {
echo 'registration sucsefull!';
}
}
else if ( $usertype == "both" ) {
$sql = "INSERT INTO webfriends (username, firstname, surname, password, alone, altwo, althree, county, country, daytime, evening, mobile, dob, email, postcode) VALUES ('$username', '$firstname', '$surname', '$password', '$alone', '$altwo', '$althree', '$county', '$country', '$alone', '$daytime', '$evening', '$mobile', '$dob', '$email')";
if (@mysql_query($sql)) {
echo 'registration sucsefull!';
$sql = "INSERT INTO customer(username, firstname, surname, password, alone, altwo, althree, county, country, daytime, evening, mobile, dob, email, postcode) VALUES ('$username', '$firstname', '$surname', '$password', '$alone', '$altwo', '$althree', '$county', '$country', '$alone', '$daytime', '$evening', '$mobile', '$dob', '$email')";
if (@mysql_query($sql)) {
echo 'registration sucsefull!';
}
} else {
echo '<p>Error adding submitted review: ' .
mysql_error() . '</p>';
}
}
// Query All entries
$result = @mysql_query('SELECT * FROM webfriends');
if (!$result) {
echo ('<p>Error performing query: ' .
mysql_error() . '</p>');
}
?>
</p>
</td>
</tr>
</table>
</body>
</head>
EDIT: Been at this one for a while now, it looks like the "usertype" isn't being passed from the form, Hense, it's ignoring all the if's and exiting. I don't know why. God I'm such a newb.