:: Forum >>
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
Monday, February 13, 2006
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)
Tuesday, February 14, 2006
<?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> </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
Wednesday, October 25, 2006
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 .="Име,Презиме,Фамилия: <input type=\"text\" name=\"ime\">";
$form .="size=\"40\" value=\"$ime\"><br>";
$form .="ЕГН: <input type=\"text\" name=\"egn\">";
$form .="size=\"20\" value=\"$egn\"><br>";
$form .="Телефон: <input type=\"text\" name=\"telefon\">";
$form .="size=\"20\" value=\"$telefon\"><br>";
$form .="Брой: <input type=\"text\" name=\"broi\">";
$form .="size=\"20\" value=\"$broi\"><br>";
$form .="Деца *от 2 до 13 години*: <input type=\"text\" name=\"deca\">";
$form .="size=\"40\" value=\"$deca\"><br>";
$form .="От дата: <input type=\"text\" name=\"otdata\">";
$form .="size=\"20\" value=\"$otdata\"><br>";
$form .="До дата: <input type=\"text\" name=\"dodata\">";
$form .="size=\"20\" value=\"$dodata\"><br>";
$form .="Начин на плащане: <input type=\"\" name=\"plashtane\">";
$form .="size=\"20\" value=\"$plashtane\"><br>";
$form.="<input type=\"submit\" name=\"submit\" ";
$form.="value=\"Приеми\"> </form>";
if ( !$submit)
{ $syobsht=$form;}
else
if (!$ime or !$egn or !$telefon or !$broi or !$deca or !$otdata or !$dodata or !$plashtane)
{ $syobsht = "Моля, попълнете всички полета<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
Saturday, February 24, 2007
This topic is archived.
Back to support forum
Forum search