chupacabrot Posted April 13, 2014 Share Posted April 13, 2014 (edited) 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! Edited April 13, 2014 by chupacabrot Quote Link to comment Share on other sites More sharing options...
chupacabrot Posted April 13, 2014 Author Share Posted April 13, 2014 or should i simply just add a simple iframe that leads to http://www.myothertestspace.com/simlpe2.php and refreshes it with the parameters when i click 'submit' ? Quote Link to comment Share on other sites More sharing options...
Skewled Posted April 13, 2014 Share Posted April 13, 2014 (edited) 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. Edited April 13, 2014 by Skewled Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted April 14, 2014 Share Posted April 14, 2014 Instead of using $_SERVER['PHP_SELF'] (which is bad), just leave that blank as "" and will go to the same page as the form was submitted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.