Jump to content

Passing parameters and sending them another URL


chupacabrot

Recommended Posts

im having a simple html form that gets variables via 'POST' and passes them to simple.php, the simple.php file constructs a new link with the $_POST[] - and all i want to do is creating a simple iframe (this script is only for internal uses) underneath the form that will open the new link that was created within simple.php

 

to clarify it a bit more

 

here's form.html

 

<form name="Students Management" action="http://myowntest.com/simple.php" method="post" accept-charset="utf-8">

<p>
<label>First Name</label>
<input type="text" value="" name="firstname"  ></input>
</p>
<p>
<label>Phone</label>
<input type="text" value="" name="phone"  ></input>
</p>
<p>
<label>Last Name</label>
<input type="text" value="" name="lastname"  required="true"></input>
</p>
<p>
<label>Company</label>
<input type="text" value="" name="school"  required="true"></input>
</p>
<p>
<label>Email</label>
<input type="text" value="" name="email"  ></input>
</p>
<p>
<label>Country</label>
<input type="text" value="" name="age"  ></input>
</p>
<p>
<input type="submit" value="Submit" ></input>
</p>
</form>

and here's simple.php

<?php

$newUrl = 'http://www.myothertestspace.com/simlpe2.php?name=' . $_POST['name'] . '&surname=' . $_POST['lastname'] . '&phone=' . $_POST['phone'];
header(Location: $newUrl);

?>

now, all i want is - after the user 'submits' the details on form.html , i'd like a new iframe will be shown up in the same page as the form that will show the user the contents of

simple.php (which means - myothertestspace.com with the new parameters).

 

thanks a lot!

I would do it like this

<?php

if (isset($_POST['submit'])) {
 // You'd want to verify the POST data though
    echo "$newUrl = 'http://www.myothertestspace.com/simlpe2.php?name=' . $_POST['name'] . '&surname=' . $_POST['lastname'] . '&phone=' . $_POST['phone']";

     }

?>

<html>
<form name="Students Management"action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8">

<p>
<label>First Name</label>
<input type="text" value="" name="firstname"  ></input>
</p>
<p>
<label>Phone</label>
<input type="text" value="" name="phone"  ></input>
</p>
<p>
<label>Last Name</label>
<input type="text" value="" name="lastname"  required="true"></input>
</p>
<p>
<label>Company</label>
<input type="text" value="" name="school"  required="true"></input>
</p>
<p>
<label>Email</label>
<input type="text" value="" name="email"  ></input>
</p>
<p>
<label>Country</label>
<input type="text" value="" name="age"  ></input>
</p>
<p>
<input type="submit" value="Submit" ></input>
</p>
</form>
</html>

You could apply some CSS and place the output into an iframe if you wanted.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.