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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bobphp
Forum Newbie
Posts: 2
Joined: Wed Dec 03, 2003 11:48 pm
Location: Texas

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

Post 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]
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
bobphp
Forum Newbie
Posts: 2
Joined: Wed Dec 03, 2003 11:48 pm
Location: Texas

Post by bobphp »

Sami and Mac thank you for your replies.

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