Bluehost.com Web Hosting $6.95

Variable not passed twixt pages..

This is a discussion on Variable not passed twixt pages.. within the PHP General forums, part of the PHP Programming Forums category; Greetings learned PHP(eople), Scenario : User fills in text box, pushes Submit and textbox data gets passed to MySQL database.. ============================================= ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-18-2003
Chris Blake
 
Posts: n/a
Default Variable not passed twixt pages..

Greetings learned PHP(eople),

Scenario : User fills in text box, pushes Submit and textbox data gets
passed to MySQL database..

=============================================
The code from the HTML page :

<form action="savemail.php" method="GET" target="main">
<input type="text" class="mailinput" name="mailaddress" value="Your
Email Address">
==================================================

The code from savemail.php :

<?php
$result = @mysql_pconnect('localhost', 'user', 'pass');
$query = "insert into email values ('" . $_REQUEST['mailaddress']
.. "')";
//Error stuff-------------------------------------------------
$ResSaveMail = mysql_query($query);
if (!$ResSaveMail)
{
echo("<P>Error performing query: " . mysql_error() . "</P>");
echo("Your email has not been saved to the Delta Database.");
exit();
}
//------------------------------------------------------------
?>
=======================================

THe problem :
The variable 'mailaddress' is not getting passed to savemail.php

echo $_REQUEST['mailaddress'] reveals blank....

On another programmers advice I tried using POST in my form, but that
don`t work either..

The database is getting populated with blank values...is my problem in
the php code somewhere..I been playing with this for a while now and no
joy has yet surfaced..

Any ideas greatly appreciated...

--
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379

Then there was the Formosan bartender named Taiwan-On.

Reply With Quote
  #2 (permalink)  
Old 07-18-2003
Nadim Attari
 
Posts: n/a
Default Re: Variable not passed twixt pages..

> <form action="savemail.php" method="GET" target="main">
....
....
....
> $query = "insert into email values ('" . $_REQUEST['mailaddress']



Use $_GET or $_POST, according to the method used...

$_GET['mailaddress']


Reply With Quote
  #3 (permalink)  
Old 07-18-2003
tj
 
Posts: n/a
Default Re: Variable not passed twixt pages..

$_REQUEST works fine, and is better than $_GET and $_POST because then your
page can work regardless of which method you used when calling it. This is
handy if you want to call a page recursively (submit a page to itself).

You need to make sure that your session is started on both your origin page
and your target page... otherwise session variables such as $_GET, $_POST,
an $_REQUEST will never be available on subsequent pages.

I use this on my master template page...
// SESSION
session_name();
session_start();
ini_set("session.cookie_lifetime","120");

My (simplified) template page structure:
// SESSION
session_name();
session_start();
// INCLUDES
require_once("cnxn.php");
require_once("header.php");
// MAIN
...


It seems to me that this behaves a little differently than ASP which I only
needed to start the session once - not on every page that I navigate to.
Can someone shed some light on that?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0