Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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..
 
Old March 10th, 2009, 08:02 AM
Friend of Wrox
 
Join Date: Sep 2005
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
The Following User Says Thank You to philip_cole For This Useful Post:
Igor Astakhov (March 10th, 2009)
 
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





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





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