Reputation: 9
I understand that this may be a duplicate post, although I am unsure how to use the posts answers in my context. I am trying to post the registered fields to the database, but if they are taken (only username and email), return to the form where the user can then edit the wrong information. Could anyone help?
I am aware that I am using deprecated tags, this is for a college project
if (isset($_POST['firstname'], $_POST['surname'], $_POST['email'], $_POST['username'], $_POST['password'], $_POST['interest'])){
$firstname = ($_POST['firstname']);
$surname = ($_POST['surname']);
$username = ($_POST['username']);
$password1 = ($_POST['password']);
$email = ($_POST['email']);
$interest = ($_POST['interest']);
$result = mysql_query("INSERT INTO user (firstname,surname,username,password,email,interestarea,user_type) VALUES ('$firstname','$surname','$username','$password1','$email','$interest','normal')");
}
if (isset($_POST['submit']))
{
?>
<script>window.location='redirect.html';</script>
<?php
}
?>
I did have something like this, but this does not work
$query2="SELECT * FROM user WHERE username='$username'";
$result2=mysql_query($query2);
$num=mysql_numrows($result2);
if ($num!=0)
{
echo "That username has already been taken, please try again<br>
<a href='register.php'>Register</a>";
exit();
}
Upvotes: 0
Views: 118