Jump to content

[SOLVED] Register Page problem


jaybeeb

Recommended Posts

Only the username and password are logged into the table, nothing else?

 

    <?php

include 'library/config.php';
include 'library/opendb.php';

?>
<form method="POST" action="register.php">
<table border="0" style="font-size: 15px; font-family: Tahoma; border: 1px">
<tr>
	 <td>
			Username:
	</td>
	<td>
			<input type="text" name="username" value="<?php echo $_POST['username']; ?>" />
	</td>
</tr>

<tr>
	<td>
			Password:
	</td>

	<td>
			<input type="password" name="password" value="<?php echo $_POST['password']; ?>" />
	</td>
</tr>
<tr>
	<td>
			Address:
	</td>

	<td>
			<input type="text" name="text" value="<?php echo $_POST['address']; ?>" />
	</td>
</tr>
<tr>
	<td>
			Phone:
	</td>

	<td>
			<input type="integer" name="text" value="<?php echo $_POST['telephone']; ?>" />
	</td>
</tr>
<tr>
	<td>
			Email:
	</td>

	<td>
			<input type="text" name="text" value="<?php echo $_POST['email']; ?>" />
	</td>
</tr>
<tr>
	<td>
			Type:
	</td>

	<td>
			<select input type="text" name="text" value="<?php echo $_POST['type']; ?>" />
			<option>Applicant</option>
			<option>Employer</option>
			</select>
	</td>
</tr>
<tr>
	<td colspan="2" align="center">	<input type="submit" name="submit" value="Register"/>
	</td>
</tr>
</table>
</form>

<?php

if($_POST['submit']) {

$username = $_POST['username'];
$password = $_POST['password'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$type = $_POST['type'];

$curnum = 0;


if(!$username)	{
	$curnum ++;
	echo "<font color='black'>" . $curnum . ". You must enter a username.</font><Br>\n";
}

if(!$password)	{
	$curnum ++;
	echo "<font color='black'>". $curnum . ". You must enter a password.</font><Br>\n";
}
if(!$address)	{
	$curnum ++;
	echo "<font color='black'>". $curnum . ". You must enter a address.</font><Br>\n";
}
if(!$telephone)	{
	$curnum ++;
	echo "<font color='black'>". $curnum . ". You must enter a telephone.</font><Br>\n";
}
if(!$email)	{
	$curnum ++;
	echo "<font color='black'>". $curnum . ". You must enter a email.</font><Br>\n";
}



$sql = "SELECT * FROM user WHERE username='".$username."'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) > 0)	{
	$curnum ++;
	echo "<font color='black'>".$curnum . ". The username '".$username."' already exists</font>\n";
}

if($curnum == 0)	{
	mysql_query("INSERT INTO user VALUES (`id`,'". $username ."', '".$password."','". $address ."','". $telephone ."','". $email ."','". $type ."')") or die(mysql_error());
 echo "<font color ='#B22222'> <H3>You have succesfuly registered as '<b>".$username."</b>'</H3></font>\n";
 echo "<a href='login3.php'><H3>Login Now</H3></a>";


}
}


?>

Link to comment
https://forums.phpfreaks.com/topic/129631-solved-register-page-problem/
Share on other sites

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.