Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2009, 11:34 PM
Authorized User
 
Join Date: Mar 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default help with passing a variable from a form field via url

<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "userform")) {
$insertSQL = sprintf("INSERT INTO clients (title, firstName, lastName, address1, address2, town, province, country, postCode, tel, email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['firstName'], "text"),
GetSQLValueString($_POST['Surname'], "text"),
GetSQLValueString($_POST['address1'], "text"),
GetSQLValueString($_POST['address2'], "text"),
GetSQLValueString($_POST['town'], "text"),
GetSQLValueString($_POST['province'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['postcode'], "text"),
GetSQLValueString($_POST['telephone'], "text"),
GetSQLValueString($_POST['email'], "text"));
mysql_select_db($database_connHotel, $connHotel);
$Result1 = mysql_query($insertSQL, $connHotel) or die(mysql_error());
$insertGoTo = "booking_details.php?$email=" . $HTTP_POST_VARS['email'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>


its not grabbing the email from the form and passing it on to the next page via the url

Last edited by Igor Astakhov; March 9th, 2009 at 11:37 PM..
Reply With Quote
  #2 (permalink)  
Old March 10th, 2009, 08:02 AM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Hi Igor,

Most of the code is using $_POST which is fine, but the line to create the url is using $HTTP_POST_VARS. $HTTP_POST_VARS is deprecated in PHP5 in favour of $_POST, and I believe it is no longer available in version 6.
Just use $_POST['email'] as with the rest of the page and it should work fine.

If for some reason this does not work, check if the email is being added to the database, as that is using the same post value.

HTH
Phil
Reply With Quote
The Following User Says Thank You to philip_cole For This Useful Post:
Igor Astakhov (March 10th, 2009)
  #3 (permalink)  
Old March 10th, 2009, 02:00 PM
Authorized User
 
Join Date: Mar 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Thumbs up

Dear Phil,

thank you very much for your help indeed it does work. See i got this old book i am working with Dreamweaver MX PHP Webdevelopment and no one replied in that forum so i came here and u helped. I really appriciate it once i am done with this one ill move on to the next newer book.

Sincerely,

Igor
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing URL parameter to form for editing markad08 Dreamweaver (all versions) 1 May 18th, 2006 03:38 PM
passing a variable from one form to another madhukp VB How-To 4 January 19th, 2005 12:45 AM
form variable passing with popups and other... jman11587 Beginning PHP 4 February 18th, 2004 10:31 PM
passing a variable through URL katie456 Classic ASP Databases 2 January 20th, 2004 11:27 PM



All times are GMT -4. The time now is 04:43 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.