how to send variables

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Mon Feb 04, 2013 10:03 pm

There are a few errors with your script

1. $_REQUEST is deprecated so shouldn't be used - use $_GET and $_POST instead

2. You can't just put html elements in the middle of PHP (i.e. you form), you need to close the PHP tags and re-open them again

3. When you send the page using your javascript it doesn't retain the posted information so you need to add it to the url and use $_GET. Based on your script you should be using PHP's header redirect instead anyway.

However, you can do this much more easily and cleanly using the script below

Code: Select all

if (isset($_GET) && $_GET['step'] == 1) {
  if (isset($_POST) && !empty($_POST['fullname']) && !empty($_POST['birthday']) && !empty($_POST['address'])) {
    echo $_POST['fullname'];
  } else {
<form action="addstuddent.php?step=1" method="POST">
      <input type="text" name="fullname">
      <input type="text" name="birthday">
      <input type="text" name="address">
      <input type="submit" value="Next" name="next">

Post Reply