Page 1 of 1

form not submitting after changing form action

Posted: Tue Oct 04, 2005 6:34 pm
by bruceg
 I have a form working great when I have it submitting to the self page
eg:

Code: Select all

<form method="post" action="{$_SERVER['PHP_SELF']}" class="info_request" >
but the specs have changed and I need it to go to a thankyou page while submitting the information submitted from the form to an email adress.
when I change to the code below, the submission DOES take you to a thank-you page as it should, but the information doesn't get submitted.

What do I need to change/alter to get this to submit while going to a different page?

again, the form works when I have:

Code: Select all

<form method="post" action="{$_SERVER['PHP_SELF']}" class="info_request" >
and down at the bottom

Code: Select all

//display information to user
  echo "<p>Hola, <strong>$firstname</strong>!.<br /><br />
We have received your request for a web site review , and will respond shortly.<br />
Thanks for visiting inspired-evolution.com and have a wonderful day!<br /><br />
Regards,<br /><br />
<strong>Inspired Evolution</strong></p>";
but when I have take out the thanks submission from the action on the form page itself to an external page, the info does not submit.

current code:

Code: Select all

<?php
$form_block=<<<END_FORM
<form action="Thanks.php" method="post" class="info_request">
<fieldset>
<legend title="Information">Information</legend> 
<table id="consultation" cellspacing="0" summary="contact form for a free consultation ">
<tr>
<td><label for="Contact_Name"><span class="red">*</span> Contact Name: </label></td> 
<td><input id="contacttname" name="contactname" type="text" value="{$_POST['contactname']}" /></td>
</tr>
<tr>
<td><label for="company"><span class="red">*</span> Company Name: </label></td> 
<td><input id="company" name="company" type="text" value="{$_POST['company']}" /></td>
</tr>
<tr>
<td><label for="URL"><span class="red">*</span> Company URL:</label></td>
<td><input id="URL" name="URL" type="text" value="{$_POST['URL']}" /></td> 
</tr>
<tr>
<td><label for="phone"><span class="red">*</span> Phone: </label></td>
<td><input id="phone" name="phone" type="text" value="{$_POST['phone']}" /></td> 
</tr>
<tr>
<td><label for="email"><span class="red">*</span> Email: </label></td>
<td><input id="email" name="email" type="text" value="{$_POST['email']}" /></td> 
</tr>
<tr>
<td><label for="email2"><span class="red">*</span> re-enter Email: </label></td>
<td><input id="email2" name="email2" type="text" value="{$_POST['email2']}" /></td> 
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td colspan="2" align="center"><label for="efforts">Current Efforts Include: (select all that apply) </label><br /></td> 
</tr>
<tr>
<td colspan="2">
<table class="checkbox">
<tr>
<td> <input type="checkbox" class="checkbox" name="SEO" value="SEO" / >SEO</td> 

<td> <input type="checkbox" class="checkbox" name="PPC" value="PPC" / >PPC</td>
</tr>
<tr>
<td><input type="checkbox" class="checkbox" name="Business_Blogging" value="Business_Blogging" / >Business Blogging 
</td>
<td> <input type="checkbox" class="checkbox" name="Email_Marketing" value="Email_Marketing" / >Email Marketing</td>
</tr>
<tr> 
<td><input type="checkbox" class="checkbox" name="Banners" value="Banners" / >Banners</td>
<td><input type="checkbox" class="checkbox" name="Other" value="Other" / >Other</td> 
</tr>
</table>
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td><label for="Hear_About_Us"> How did you hear about us?: </label></td> 
<td><input id="About" name="About" type="text" value="{$_POST['About']}" /></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr><td><strong>Comments:</strong></td></tr> 
<tr>
<td colspan="2"><textarea name="Comments" id="Comments" rows="" cols="" > </textarea></td>
</tr>
<td colspan="2" align="right"> 

<input class="submit" src="submit.gif" alt="Submit" type="image" name="submit"  />
</td>
</tr>
</table> 
</fieldset>


<input type="hidden" name="op" value="ds" />

</form>
</div>

END_FORM;
if ($_POST['op']!='ds') { 
    echo "$form_block";
    } else if ($_POST["op"] == "ds")  {

//Function saves time and space by eliminating unneccesary code
function check($fieldname)
 {
 global $err_msg;
 if($_POST[$fieldname] == "")
  { 
  if ( !isset($err_msg)) { $err_msg = "<span class='red'>You haven't entered your ".$fieldname."!</span><br />"; } 
  elseif ( isset($err_msg)) { $err_msg="<span class='red'>You haven't entered your ".$fieldname."!</span><br />"; }
  }
 return $err_msg;
 }

//////////////////////////
///Function execution/////
//////////////////////////

check('contactname');
check('URL');
check('company');
check('phone');
check('email');
check('email2');


//Validating Email Address
if ($_POST['email'] != $_POST['email2']) { $email_err = "\n<span class='red'>e-mail address fields do not match!</span>"; }

if (isset($err_msg) || isset($email_err)) { echo $err_msg.$email_err."\n\n".$form_block; }
else {
  //it's ok to send, so build the mail
        $msg = "E-mail sent from http://www.fortuneinteractive.com\n";
        $msg .="Contact Name:{$_POST['contactname']}\n";
        $msg .="Contact web site is: {$_POST['URL']}\n";
        $msg .="Company Name:{$_POST['company']}\n"; 
        $msg .="Contact Phone number:{$_POST['phone']}\n";
        $msg .="Contact email address: {$_POST['email']}\n";
        $msg .="Contact email address (re-typed): {$_POST['email2']}\n"; 
        $msg .="Current Effort(s):  {$_POST['SEO']}\n";
        $msg .="Current Effort(s): {$_POST['PPC']}\n";
        $msg .="Current Effort(s): {$_POST['Business_Blogging']}\n";
  $msg .="Current Effort(s): {$_POST['Banners']}\n";
   $msg .="Current Effort(s): {$_POST['Email_Marketing']}\n";
   $msg .="Current Effort(s): {$_POST['Banners']}\n";
   $msg .="Another Current Effort: {$_POST['Other']}\n"; 
    $msg .="I heard about Fortune Interactive from:{$_POST['About']}\n\n";
        $msg .="Comments:{$_POST['Comments']}\n\n";
        $to =" bgilbert@fortuneinteractive.com";
        $subject ="Potential client alert!";
        $mailheaders ="From: the fortune interactive website
        < http://www.fortuneinteractive.com>\n";
        $mailheaders .="Reply-To: {$_POST['email']}\n";
        //send the mail
        mail ($to, $subject, $msg, $mailheaders);
       
 }
} 


?>
thanks in advance for any help that can be given!!

Posted: Tue Oct 04, 2005 7:59 pm
by feyd
you cannot go to two different pages at the same time. Have the "thank you" page do the emailing...

Posted: Tue Oct 04, 2005 9:39 pm
by bruceg
thanks for your reply. I don't see in my code where to change that, however. Please provide specifics to what I would need to change!

thx,

Posted: Wed Oct 05, 2005 5:45 pm
by bruceg
just wanted to revisit this tonight as I still haven't resolved this problem! I know I need to change to get the Thanks form to submit, but not sure how.

See my post above for the full details.

Posted: Wed Oct 05, 2005 8:09 pm
by John Cartwright
Have your action set to a processing page which will

a) Handle the database insertion
b) display a thank you message
c) redirect the user

instead of the same page of the form (If I understand correctly)

Posted: Wed Oct 05, 2005 8:54 pm
by bruceg
yes, I understand that I need to set on the Thanks.php page the thanks text, but would I need to add all the PHP stuff to that page as well or leave on the form page. THIS is what I am trying to figure out!

if I use:

form action="Thanks.php" method="post" class="info_request">

what part of the form code would I need to add to the Thanks page?