Jump to content


Photo

Need help with passing form variables


  • Please log in to reply
7 replies to this topic

#1 moviejunkie

moviejunkie
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 August 2006 - 10:21 AM

Hi I am trying to create a contact form where a user can select an option in a combo box then pass it to a php script then it will send out the information in the form to a diffrent email address according to what is selected.  I can not get it to work.  Here is my code

HTML Form Code:

<form name="form1" method="post" action="process.php">
  <label>What are you contacting us concerning
  <select name="type" id="type">
    <option value="general" selected>General Information</option>
    <option value="jesse">Contact Pastor Jesse</option>
    <option value="prayer">Prayer Request</option>
    <option value="victory">Victory Report</option>
    <option value="enlist">Enlistment Information</option>
    <option value="dexter">Dexter Lake Church of God</option>
    <option value="web">Dexter Lake Web Team</option>
    </select>
  <br>
  <br>
  Name
    <input name="name" type="text" id="name">
    <br>
    E-Mail
    <input name="email" type="text" id="email">
    <br>
    Prayer Request*
    <textarea name="prayerRequest" id="prayerRequest"></textarea>
    <br>
    <br>
    *= Required <br>
    </label>
  <label></label>
  <input type="submit" name="Submit" value="Submit">
</form>

Process.php code:
<?php
$type = $_GET('type');
$name = $_GET("name");
$email = $_GET('email');
$prayerrequest = $_GET('prayerRequest');
if ( $type == "General Information")
{
$sendemail = "moviejunkie@gmail.com";
$subject = "Requesting General Information from the HeirForce Web Site";
}
if ( $type == "Prayer Request")
{
$sendmail = "moviejunkie@gmail.com";
$subject = "Prayer Request from HeirForce Web Site";
}
mail($sendmail, $subject ,"From: $name <$email> -- $prayerRequest");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "http://www.yourdomai...yourpage.html";
//-->
</script>

(Also if there another way to redirect after the process that would be awsome)

Thank you so much for your help.

#2 stillatmycomputer

stillatmycomputer
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 August 2006 - 11:50 AM

You have your <form method="post"  so use $_POST instead of $_GET to access your variables.

Redirect like this:
<?php header("Location: http://www.yoursite....m/thankyou.php"); ?>

#3 moviejunkie

moviejunkie
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 09 August 2006 - 05:26 PM

That does not work, this is the error I get Fatal error: Call to undefined function: array() in /home/www/heirforcetest.awardspace.com/process.php on line 9

#4 onepixel

onepixel
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 09 August 2006 - 11:14 PM

Use $_POST global array instead with square barckets [ ] instead of parenthesis i.e $_POST['email']

<a href="http://www.saheltech.com">PHP Programming - WordPress Blog Customization</a>

#5 moviejunkie

moviejunkie
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 10 August 2006 - 11:12 AM

ok that works now, but now it wont send the email......

#6 aaronwalker1111

aaronwalker1111
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 11 August 2006 - 09:19 PM

well... look at

if ( $type == "General Information")
{
   $sendemail = "moviejunkie@gmail.com";
   $subject = "Requesting General Information from the HeirForce Web Site";
}


I'm not that great at php but shouldn't it be $sendmail ?

and to redirect you can use
header("Location:http://www.somesite.com");

#7 moviejunkie

moviejunkie
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 11 August 2006 - 10:24 PM

yes I caught that but it still will not send the email.

#8 aaronwalker1111

aaronwalker1111
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 12 August 2006 - 04:40 AM

and i'm just guessing cause i've never done a mail script but i think there's supposed to be a message. so i guess you could do

mail($sendmail, $subject,  $prayerRequest (this is where the message goes), From: $name <$email>);

or something like that




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users