Hi I'm struggling with my contact form and php - I'm new to all this and trying to understand the sequence of events. The first time the contact form is loaded is from this link:
Then it's loaded again when I click Submit!HTML Code:<li class="accordionButton"><a class="rfpMenuBtn" href="contactform.php?id=1">Contact us</a></li>
- I guess it's a case of before and after the form is filled, but it seems strange the page loading itself again!HTML Code:<form style="margin-left: 10em;" id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
My question is how do I pass the parameter that was passed in the original link ( href="contactform.php?id=1") to the contact form when it's loaded the second time after clicking Submit ?
Here's the full contact form page:
Thanks for any helpPHP Code:<?PHP
/*
Contact Form from HTML Form Guide
This program is free software published under the
terms of the GNU Lesser General Public License.
See this page for more info:
http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html
*/
require_once("./include/fgcontactform.php");
$formproc = new FGContactForm();
$var1=$_GET['id'];
switch($var1)
{
case 3:
echo 'send to david';
$formproc->AddRecipient('davidm.me@gmail.com'); //<<--- Web Masters address
break;
default:
echo 'send to rahel';
$formproc->AddRecipient('reikiforpeace@gmail.com'); //<<--- Rahel
break;
}
//2. For better security. Get a random tring from this link: http://tinyurl.com/randstr
// and put it here
$formproc->SetFormRandomKey('CnRrspl1FyEylUj');
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
<?php
include ("include/head-section.php");
?>
<style type="text/css">
<!--
body {
margin: 0;
padding: 0;
}
fieldset {
float: left;
/* clear: both; */
width: auto;
margin: 0 0 1.5em 0;
margin-left: 10em;
padding: 0;
border: 1px solid #BFBAB0;
background-color: #F2EFE9;
}
-->
</style>
</head>
<body>
<div id="screenWrapper">
<!-- see http://cooltext.com/ to generate a logo like this
<img src="images/reikiforpeace.png" alt="reiki for peace logo" style="position: absolute; top: 75px; right: 130px;"></img>
-->
<?php include('include/header.php'); ?>
<?php include('include/menu.php'); ?>
<!-- Form Code Start -->
<div style="margin-top: 2.3em;">
<?php
echo
"$formproc->GetSelfScript()'?='$_GET['id']. \n";
?>
<form style="margin-left: 10em;" id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset id="fset">
<?php
//$var1=$_GET['id'];
//switch($_GET['id'])
switch($var1)
{
case 1:
echo "<legend style='margin-top: 1em; font-size: 1.4em; font-weight: normal; color: #a6a6a6; text-align: left;'>Contact us</legend>";
break;
case 2:
echo "<legend style='margin-top: 0.5em; font-size: 1.4em; font-weight: normal; color: #a6a6a6; text-align: left;'>Contact Rahel Warshaw-Dadon </legend>";
echo "<span style='font-size: 12pt; color: grey; text-align: center;'> Reiki Master and Director of Reiki for Peace</span><br/>";
break;
case 3:
echo "<legend style='margin-top: 1em; font-size: 1.4em; font-weight: normal; color: #a6a6a6; text-align: left;'>Contact David Myers - Web Master</legend>";
break;
default:
echo "Try Again, the id was ". $var1 . "<br />";
break;
}
?>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>* required fields</div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='name'>* Your Name: </label>
<label style="float: left; margin-left: 170px; clear: right;" for='email'>* Your Email Address:</label>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" />
<input style="margin-left: 20px;" type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
<input style="margin-left: 50px;" type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</div>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->
<script type='text/javascript'>
// <![CDATA[
var frmvalidator = new Validator("contactus");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email address");
frmvalidator.addValidation("email","email","Please provide a valid email address");
frmvalidator.addValidation("message","maxlen=2048","The message is too long!(more than 2KB!)");
// ]]>
</script>
<div id='fg_crdiv'><p>for customization, <a href='http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html'
>see the contact form code page</a>.</p></div>
<!--
Form Code End
Visit html-form-guide.com for more info.
-->
</div>
<?php include('include/footer.php'); ?>
</body>
</html>
David


Reply With Quote
Bookmarks