Confusing request

Status
Not open for further replies.

LeCeejay

Member
Dec 25, 2010
122
17
Right, I want a page with TWO boxes on it.. which you input your name. E.G Bob and last name E.G Phillips

BUT heres' the confusing part, I want it so it READS the name inputted, and depending on the name inputted, it goes to a different page reading;

Input:
First: Bob Last: Phillips (Reads it, and redirects to )

Anyone any idea how D:? I had a few idea's but I'm shit with PHP so I can't figure out how to do it xD
 

Pure

Knock Knock..
Aug 3, 2010
14
4
Yeah, it's called research.. How about you google, basic if statements and header redirects. :)

Oh look.. links inbound:




Don't leech, learn. :)
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,921
Here's a very basic way to accomplish this:


PHP:
<?php
if(isset($_POST['first_last'])) {
 
    header('Location: ' . $_POST['first'] . '_' . $_POST['last'] . '.php');
 
}else{
?>
<form action="" method="post">
   
    <input name="first" type="text" /> <input name="last" type="text" /><br />
    <br />
    <input type="submit" name="first_last" value="Go!" />
   
</form>
<?php
}
?>
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Should work.

PHP:
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['first_name']) && isset($_POST['last_name']))
{
header("Location: {$_POST['first_name']}_{$_POST['last_name']}.php");
}
else
{
$error[] = 'Fill in all fields';
}
}
 
?>
 
<html>
<head><title> My nub script</title></head>
<body>
<?php foreach($error as $key => $value) { echo $value; } ?>
<form method="POST" action="index.php">
<input type="text" name="first_name" placeholder="Firstname" />
<input type="text" name="last_name" placeholder="Lastname" />
<input type="submit" name="submit" value="submit" />
</form>
 
</body>
</html>
 
Status
Not open for further replies.

Users who are viewing this thread

Top