first time questioner!
I am making a registration form and I have it all submitting into my database, however I want it to report back to the page when a user has missed out some details or there is already an email address registered etc.
At the moment I can just pump the same data in continually and wondered how to go about this.
My form currently posts to another php file so getting feedback back from this is confusing me.
Currently if a user registers this happens on join.php (where they join from with the html forms):
$join = $_GET['success'];
if($join=='yes')
{
echo "Well done!";
}
?>
Because in signup.php (where the queries are) it sets this if they are registered.
header('Location: join.php?success=yes');
This is very basic though...
<h1>Sign Up Form</h1>
<p>Please join today!</p>
<label>Username
<span class="small">Type a username.</span>
</label>
<input type="text" name="un" id="un" maxlength="100" tabindex="1" />
<label>Password
<span class="small">Type a password.</span>
</label>
<input type="password" name="pw" id="pw" maxlength="100" tabindex="2" />
<label>Confirm Password
<span class="small">Confirm your password.</span>
</label>
<input type="password" name="pw2" id="pw2" maxlength="100" tabindex="3" />
<div class="space"></div>
<label>Title
<span class="small">Select your title.</span>
</label>
<select name="titleName" id="titleName" tabindex="4">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
<!--Standard form requirements are captured for users with a well designed layour of ordered boxes and set chracter limits. The tab indexes are in order for ease of use and sense to the user.-->
<label>First Name
<span class="small">Type your first name.</span>
</label>
<input type="text" name="firstName" id="firstName" maxlength="100" tabindex="5" />
<label>Last Name
<span class="small">Type your last name.</span>
</label>
<input type="text" name="lastName" id="lastName" maxlength="100" tabindex="6" />
<label>Email
<span class="small">Type a valid email address.</span>
</label>
<input type="email" name="email" id="email" maxlength="100" tabindex="7" />
<label>Address
<span class="small">Type your address here. <br> (500 character limit)</span>
</label>
<textarea name="address" rows = "5" id="address" cols="20" maxlength="500" tabindex="8"></textarea>
<label>Postcode
<span class="small">Enter your postcode. <br> Eg: CV1 23H.</span>
</label>
<input type="text" name="postcode" id="postcode" maxlength="100" tabindex="9" />
<div class="space"></div>
<button input type="reset" tabindex="10">Reset</button>
<button input type="submit" tabindex="11">Submit</button>
</form>
//SIGNUP.PHP<?php
$password=$_POST["pw"];
$password2=$_POST["pw2"];
if($password==$password2)
{
$conn = new PDO("mysql:host=host;dbname=DB",'UN','PASSWORD');
$id=null;
$user=$_POST["un"];
$pass=$_POST["pw"];
$title=$_POST["titleName"];
$fn=$_POST["firstName"];
$ln=$_POST["lastName"];
$email=$_POST["email"];
$address=$_POST["address"];
$postcode=$_POST["postcode"];
$q=$conn->prepare('INSERT INTO Users(idUsers,username,password,title,firstName,lastName,email,address,postcode)
VALUES(?,?,?,?,?,?,?,?,?)');
$q->execute(array($id,$user,$pass,$title,$fn,$ln,$email,$address,$postcode));
$affected_rows = $q->rowCount();
$conn=null;
header('Location: join.php?success=yes');
}
else
{
header('Location: index.php');
}
?>