...

View Full Version : Verification Form



th3gh05t
04-21-2004, 06:14 AM
Hi,

I am interested in making a page where it has a text box and a Submit button. And if the ext that is entered is correct, it redirects to another page. If it is wrong, it redirects to an error page.

I have this code so far:



<?
if ($question)
{
if ($question=='DevsDancin, devsdancin, ladybug070, Ladybug070')
{
header("Location: fullurlofpage")
}
else
{
header("Location: fullurlofwrongpage");
}
}
?>

Can you please help me out?

Thanks, th3gh05t

raf
04-21-2004, 03:59 PM
Welcome here !

Your explanation is rather vague so i might be off here.
Supposing that the textbox is called 'test' and the you post the form using the postmethod, and that the complete value of $_POST['test'] needs to be one of the values from $question, then you'd have


<?php
$question= array('DevsDancin', 'devsdancin', 'ladybug070', 'Ladybug070');
if (in_array($_POST['test'],$question)){
header('Location: fullurlofpage')
} else {
header('Location: fullurlofwrongpage');
}
?>

th3gh05t
04-21-2004, 08:12 PM
Ok.

But where do I put that code?

I have this so far:


<html>
<head>
<title>Untitled Document</title>
</head>
<?php
$question= array('DevsDancin', 'devsdancin', 'ladybug070', 'Ladybug070');
if (in_array($_POST['test'],$question)){
header('Location: fullurlofpage')
} else {
header('Location: fullurlofwrongpage');
}
?>
<body>
<form name="form1" method="post" action="">
<input name="test" type="text" id="test">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Nightfire
04-21-2004, 08:28 PM
<?php
$question= array('DevsDancin', 'devsdancin', 'ladybug070', 'Ladybug070');
if (in_array($_POST['test'],$question)){
header('Location: fullurlofpage')
} else {
header('Location: fullurlofwrongpage');
}
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="">
<input name="test" type="text" id="test">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Headers have to be before any output to the browser, which includes html

th3gh05t
04-21-2004, 08:56 PM
I get this error:

Parse error: parse error in /home/drossler/www/test.php on line 5

Nightfire
04-21-2004, 08:59 PM
Missing semi-colon at the end of this line

header('Location: fullurlofpage');

th3gh05t
04-21-2004, 09:08 PM
Ok. This is what I have now. When I load up the page, there are no errors, and when I enter a value into the text box and hit Submit, nothing happens. The text gets cleared, and looks like the page reloads.


<?php
if ($question)
{
$question= array('DevsDancin', 'devsdancin', 'ladybug070', 'Ladybug070');
if (in_array($_POST['test'],$question)){
header('Location: http://www.google.com');
} else {
header('Location: http://news.google.com');
}
}
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
Enter AIM Name: <br>
<form name="form1" method="post" action="">
<p>
<input name="test" type="text" id="test">
<input type="submit" name="Submit" value="Submit">
<br>
<i><font color="#FF0000">*case senstive.</font></i>
</p>
</form>
</body>
</html>

Nightfire
04-21-2004, 10:05 PM
Change this line:


if ($question)

to


if (isset($_POST['Submit']))

stophon4
04-21-2004, 11:12 PM
And also put the name of the page you are making in the action="" spot :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum