The query is pretty-much correct. All you need to do is have it say:
$result = $xxx->db->query("SELECT `email` FROM `tablename` WHERE `email` = '" . mysql_real_escape_string($_POST['email']) . "'");
The [man]mysql_real_escape_string/man function just escapes special characters from the user input. Just helps safeguard against SQL injection. But you had it right if you had just replaced the "?" with the form email address input field 😉
Now, you can then just check the number of rows returned using [man]mysql_num_rows/man. If it's 1, then you redirect based upon user input to a, b, or c:
if(mysql_num_rows($result) == 1)
{
$page = $_POST['redirect'];
header('Location: ' . $page . '.php');
}
Otherwise, you'd redirect to a2, b2, c2:
else
{
$page = $_POST['redirect'];
header('Location: ' . $page . '2.php');
}
So, putting it all together, you have this:
$result = $xxx->db->query("SELECT `email` FROM `tablename` WHERE `email` = '" . mysql_real_escape_string($_POST['email']) . "'");
$page = $_POST['redirect'];
if(mysql_num_rows($result) == 1)
{
header('Location: ' . $page . '.php');
}
else
{
header('Location: ' . $page . '2.php');
}
That is of course if your form is set up something like this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="email">Email Address:</label> <input type="text" name="email" id="email" /><br />
<label>Redirect To:</label><br />
<input type="radio" name="redirect" id="a" value="a"> <label for="a">a</label>
<input type="radio" name="redirect" id="b" value="b"> <label for="b">b</label>
<input type="radio" name="redirect" id="c" value="c"> <label for="c">c</label><br />
<input type="submit" name="submit" value="Submit" />
</form>
Hope that helps.