3.2.0

insert data into a form mailer from another page

Hi, I'm new to this web design stuff so hopefully this is not a silly question.

I have a form mailer on my site for booking tours, currently the user selects a tour from a drop down list.

If the user gets to the booking page from a page which provides information on a specific tour, i'd like that tour to automatically appear in place of the drop down list.

(eg, you've decided you want to do a 3 day Ayers Rock tour, so you "click book this tour" you are then taken to a booking page, I don't want you to have to select that tour again from a drop down list, I'd like this tour to appear in place of the drop down list.)

Essentially I need to get the data (tour name) from the first page, and then insert it in the form mailer on the booking page.

If someone knows a website where I could learn how to do this, or even tell me what this process is called, I'd be more than grateful.

Thankyou
Tim
February 13,
Your need a server-side language, not javscript this site will only help you if you are using Active Widgets. Take a look into PHP, ASP, JSP, Python
Tony (www.FriendsOfAW.com)
February 14,
<?php
/* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates!
(easy to use and more secure than many cgi form mailers) FREE from:
www.TheDemoSite.co.uk
Should work fine on most Unix/Linux platforms */

// ------- three variables you MUST change below -------------------------------------------------------
$valid_ref1="http://Your--domain/contact.html";// chamge "Your--domain" to your domain
$valid_ref2="http://www.Your--domain/contact.html";// chamge "Your--domain" to your domain
$replyemail="YOU@Your--domain";//change to your email address
// ------------------------------------------------------------

//clean input in case of header injection attempts!
function clean_input_4email($value, $check_all_patterns = true)
{
$patterns[0] = '/content-type:/';
$patterns[1] = '/to:/';
$patterns[2] = '/cc:/';
$patterns[3] = '/bcc:/';
if ($check_all_patterns)
{
$patterns[4] = '/\r/';
$patterns[5] = '/\n/';
$patterns[6] = '/%0a/';
$patterns[7] = '/%0d/';
}
//NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0.
return preg_replace($patterns, "", strtolower($value));
}

$name = clean_input_4email($_POST["name"]);
$email = clean_input_4email($_POST["email"]);
$thesubject = clean_input_4email($_POST["thesubject"]);
$themessage = clean_input_4email($_POST["themessage"], false);

$error_msg='ERROR - not sent. Try again.';

$success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
<p align="center"><strong>Your message has been successfully sent to us<br>
</strong> and we will reply as soon as possible.</p>
<p align="center">A copy of your query has been sent to you.</p>
<p align="center">Thank you for contacting us.</p>';

$replymessage = "Hi $name

Thank you for your email.

We will endeavour to reply to you shortly.

Please DO NOT reply to this email.

Below is a copy of the message you submitted:
--------------------------------------------------
Subject: $thesubject
Query:
$themessage
--------------------------------------------------

Thank you";

// email variable not set - load $valid_ref1 page
if (!isset($_POST['email']))
{
echo "<script language=\"JavaScript\"><!--\n ";
echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
exit;
}

$ref_page=$_SERVER["HTTP_REFERER"];
$valid_referrer=0;
if($ref_page==$valid_ref1) $valid_referrer=1;
elseif($ref_page==$valid_ref2) $valid_referrer=1;
if(!$valid_referrer)
{
echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";
echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
exit;
}
$themessage = "name: $name \nQuery: $themessage";
mail("$replyemail",
"$thesubject",
"$themessage",
"From: $email\nReply-To: $email");
mail("$email",
"Receipt: $thesubject",
"$replymessage",
"From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;
/*
PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form mailers)
FREE from:

www.TheDemoSite.co.uk */
?>
nana
October 25,
ok i have problem with my code
i hope somebody can help me... i want to put select form in that code and selected option to be writed in same table like other text form
but i can't do it!!!

thanks

<body>
<?php
$self = $_SERVER['PHP_SELF'];
$ime = $_POST['ime'];
$egn = $_POST['egn'];
$telefon = $_POST['telefon'];
$broi = $_POST['broi'];
$deca = $_POST['deca'];
$otdata = $_POST['otdata'];
$dodata = $_POST['dodata'];
$plashtane = $_POST['plashtane'];
$submit = $_POST['submit'];

$form ="<form action=\"$self\" method=\"post\"> ";
$form .="&#1048;&#1084;&#1077;,&#1055;&#1088;&#1077;&#1079;&#1080;&#1084;&#1077;,&#1060;&#1072;&#1084;&#1080;&#1083;&#1080;&#1103;: <input type=\"text\" name=\"ime\">";
$form .="size=\"40\" value=\"$ime\"><br>";

$form .="&#1045;&#1043;&#1053;: <input type=\"text\" name=\"egn\">";
$form .="size=\"20\" value=\"$egn\"><br>";

$form .="&#1058;&#1077;&#1083;&#1077;&#1092;&#1086;&#1085;: <input type=\"text\" name=\"telefon\">";
$form .="size=\"20\" value=\"$telefon\"><br>";

$form .="&#1041;&#1088;&#1086;&#1081;: <input type=\"text\" name=\"broi\">";
$form .="size=\"20\" value=\"$broi\"><br>";


$form .="&#1044;&#1077;&#1094;&#1072; *&#1086;&#1090; 2 &#1076;&#1086; 13 &#1075;&#1086;&#1076;&#1080;&#1085;&#1080;*: <input type=\"text\" name=\"deca\">";
$form .="size=\"40\" value=\"$deca\"><br>";

$form .="&#1054;&#1090; &#1076;&#1072;&#1090;&#1072;: <input type=\"text\" name=\"otdata\">";
$form .="size=\"20\" value=\"$otdata\"><br>";

$form .="&#1044;&#1086; &#1076;&#1072;&#1090;&#1072;: <input type=\"text\" name=\"dodata\">";
$form .="size=\"20\" value=\"$dodata\"><br>";

$form .="&#1053;&#1072;&#1095;&#1080;&#1085; &#1085;&#1072; &#1087;&#1083;&#1072;&#1097;&#1072;&#1085;&#1077;: <input type=\"\" name=\"plashtane\">";
$form .="size=\"20\" value=\"$plashtane\"><br>";

$form.="<input type=\"submit\" name=\"submit\" ";
$form.="value=\"&#1055;&#1088;&#1080;&#1077;&#1084;&#1080;\"> </form>";


if ( !$submit)
{ $syobsht=$form;}
else

if (!$ime or !$egn or !$telefon or !$broi or !$deca or !$otdata or !$dodata or !$plashtane)
{ $syobsht = "&#1052;&#1086;&#1083;&#1103;, &#1087;&#1086;&#1087;&#1098;&#1083;&#1085;&#1077;&#1090;&#1077; &#1074;&#1089;&#1080;&#1095;&#1082;&#1080; &#1087;&#1086;&#1083;&#1077;&#1090;&#1072;<br><br>";
$syobsht.=$form;}

else
{ $conn=mysql_connect("localhost", "root")
or die ("neuspeshen opit");

$r = mysql_select_db("klienti", $conn)
or die ("neuspeshen opit 2");

if($ime and $egn)
{ $zaiavka ="insert into gosti (ime,egn,telefon,broi,deca,otdata,dodata,plashtane)
values (\"$ime\", \"$egn\", \"$telefon\", \"$broi\", \"$deca\", \"$otdata\", \"$dodata\", \"$plashtane\" )";
$r = mysql_query($zaiavka, $conn)
or die ("nema"); }

if ($r)
{ $syobsht = "thank you";
}
}
echo ($syobsht);
?>


</body>
Cvetomira
February 24,

This topic is archived.

See also:


Back to support forum