Page 1 of 1

[SOLVED] Passing Parm from .php to .php with using form.

Posted: Wed Dec 03, 2003 11:48 pm
by bobphp
Hi, I am a new user of PHP. I am doing a project with MySQL . I want to be able to pass info in the following manner, but there seems to a restriction?

Code: Select all

r.php ========================
 <html>
  <head>
  </head>
    <title>Registration Page
    </title>

    <style type="text/css">
      body {background-color: #ffffc0}
    </style>

  <body>
  <?php
    include("logo.html");
    include("menu.html");
    include("register\\r.html");
    include("trailer.html");
  ?>
  </body>
</html>

r.html ===========================
<form action="pr.php" method="post">
  <input type="text" name="val">
  <input type='submit'>
</form>

pr.php ===========================
< form action="rdb.php method="post">
<?php
  $val = $_POST['val'];
?>
  <input type="submit" value="submit">
</form>

rdb.php ===========================
<?php
$val = $_POST['val'];
?>
================================
This gives the following error:

Notice: Undefined index: val in D:\WebApps\rdb.php on line 2
================================
How can I pass val to the rdb.php from pr.php?

I have about 12 parms to pass. Do i need to use the URL way of passing parms? or is there a way to use $_GET or $POST?

[Added php tags for eyecandy --JAM]

Posted: Thu Dec 04, 2003 12:03 am
by m3mn0n
Turn your error reporting down in php.ini. That might be it.

Make a new PHP file and add this within it only...

Code: Select all

<?php
echo '<pre>'; 
echo 'PHP Version: '.phpversion()."\n"; 
echo 'Display Errors: '.(ini_get('display_errors') == '1' ? 'On' : 'Off')."\n"; 
echo 'Error Level: '.(ini_get('error_reporting') == '2047' ? 'E_ALL' : 'Not E_ALL')."\n"; 
echo 'Register Globals: '.(ini_get('register_globals') == '' ? 'Off' : 'On')."\n"; 
echo '</pre>'; 
?>
Post the results here

Posted: Thu Dec 04, 2003 2:49 am
by twigletmac
Sami wrote:Turn your error reporting down in php.ini. That might be it.
Turning your error reporting down is not a solution, it hides problems instead of fixing them.

The reason this error is occuring is because you are not passing the value of $_POST['val'] from pr.php to rdb.php. To do this you could use a hidden field, so on pr.php instead of:

Code: Select all

< form action="rdb.php method="post">
<?php
$val = $_POST['val'];
?>
<input type="submit" value="submit">
</form>
you have

Code: Select all

< form action="rdb.php method="post">
<input type="hidden" name="val" value="<?php echo $_POST['val']; ?>" />
<input type="submit" value="submit">
</form>
Mac

Posted: Thu Dec 04, 2003 9:15 am
by bobphp
Sami and Mac thank you for your replies.

Mac the input type =hidden works fine. Thank you very much.