Welcome Guest!

If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:

  • Receive Fast Advice
  • Learn Programming Languages
  • Get Professional Website Reviews
  • Quick Troubleshooting Assistance

> Php Forms.. Lol...

This is a discussion on Php Forms.. Lol..., within the PHP section. This forum and the thread "Php Forms.. Lol..." are both part of the Programming Your Website category.

 
Reply to this topicStart new topic
> Php Forms.. Lol...
mcdanielnc89
post Jun 23 2008, 08:48 PM
Post #1


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


Okay yo PHP Guru's lol... I need MAJOR help.. I have tried creating a php form to email and i'm getting no where!!!!!! I can't figure otu hwo to email them. and some peopel are even saying i've done it totally wrong, LOL..Here is the coding...

CODE
<html>
<head>
<title>TITLE HERE</title>
</head>
<body>
<font size="20"><p style="text-align:center">Staff Application</p></font>
<form method="post" action="sendemail.php" method="post">
First Name: <input type="text" size="20" maxlength="40" name="Fname"><br />
Last Name:  <input type="text" size="20" maxlength="40" name="Lname"><br />
<br />
Valid E-mail Address:<br />
<input type="text" size="50" maxlength="100" name="email"><br />
<br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender">
Female:<input type="radio" value="Female" name="gender"><br />
<br />
Age:<br />
<select name="age">
<option value="13-18">13-18</option>
<option value="19-25">19-25</option>
<option value="26-32">26-32</option>
<option value="33-41">33-41</option>
<option value="42-48">42-48</option>
<option value="49-54">49-54</option>
<option value="55-61">55-61</option>
<option value="62-68">52-68</option>
<option value="69-75">69-75</option>
<option value="76-82">76-82</option>
<option value="83+">83+</option></select>
<br />
<br />
What state/province are you in?<br />
<input type="text" size="25" maxlength="40" name="location"><br />
<br />
Are you a Christian?<br />
<select name="christian">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br />
<br />
Please check all that apply to you:<br />
<input type="checkbox" value="a College Student" name="etc[]">College Student
<input type="checkbox" value="a High-School Student" name="etc[]">High-School Student
<input type="checkbox" value="a Middle School/Jr. High Student" name="etc[]">Middle School/Jr. High Student<br />
<input type="checkbox" value="Out of School" name="etc[]">Out of School
<input type="checkbox" value="Unemployed" name="etc[]">Unemployed
<input type="checkbox" value="Employed" name="etc[]">Employed<br />
<input type="checkbox" value="Retired" name="etc[]">Retired<br />
<br />
How long have you been a member of NBJF?<br />
<input type="text" size="25" maxlength="40" name="current"><br />
<br />
Why do you want to be apart of the NBJF Staff?:<br />
<textarea rows="5" cols="40" name="whyonstaff" wrap="physical"></textarea><br />
<br />
What/how can you contribute to NBJF?<br />
<textarea rows="5" cols="40" name="howcanyou" wrap="physical"></textarea><br />
<br />
How often do you have access to the internet?:<br />
<select name="howmany">
<option value="Less than 6 hrs. a day">Less than 6 hrs. a day</option>
<option value="2-3 times">2-3 times</option>
<option value="6+ times">6+ times</option>
<option value="Off and on throughout the day">Off and on throughout the day</option></select>:<br />
<br />
MSN/Windows Live Messenger:<br />
<input type="text" size="40" maxlength="50" name="msn"><br />
<br />
Yahoo Messenger:<br />
<input type="text" size="40" maxlength="50" name="yahoo"><br />
<br />
AIM:<br />
<input type="text" size="40" maxlength="50" name="aim"><br />
<br />
Skype:<br />
<input type="text" size="40" maxlength="50" name="skype"><br />
<br />
<input type="submit" value="Submit" name="submit"><br />
<br />
</form>

CODE
<html>
<head>
<title></title>
</head>
<body>
<?php

$to = "admin@newbreedjesusfreaks.com";
$subject = "Staff Application";
$message = "
<b>Name:</b><br /><?php echo $_POST["$Fname"]; ["$Lname"]; ?><br />
<br />
<b>Valid E-mail Address:</b><br /><?php echo $_POST["email"]; ?><br />
<br />
<b>Gender:</b><br /><?php echo $_POST["$gender"]; ?><br />
<br />
<b>Age:</b><br /><?php echo $_POST["$age"]; ?><br />
<br />
<b>Location:</b><br /><php echo $_POST["$location"]; ?><br />
<br />
<b>Am I a Christian?</b><br /><?php echo $_POST["$christian"]; ?><br />
<b>I am:</b><br /><php echo $_POST foreach["$etc as $e"]; ?><br />
<br />
<br />
<b>How long have I been a member of NBJF?</b><br /><?php echo $_POST["$current"]; ?><br />
<br />
<b>Why I would like to be on the NBJF Staff.</b><br /><php echo $_POST["$whyonstaff"]' ?><br />
<br />
echo "<b>What/how can I contribute to NBJF?</b><br /><?php echo $_POST["$howcanyou"]; ?><br />
<br />
<b>How often I am online.</b><br /><?php echo $_POST["$howmany"]; ?><br />
<br />
<b>MSN/Windows Live Messenger:</b><br /><?php echo $_POST["$msn"]; ?><br />
<br />
<b>Yahoo Messenger:</b><br /><?php echo $_POST["$yahoo"]; ?><br />
<br />
<b>AIM:</b><br /><?php echo $_POST["$aim"]; ?><br />
<br />
<b>Skype:</b><br /><php echo $_POST["$skype"]; ?><br />
";

?>
</body>
</html>


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
Jason
post Jun 24 2008, 12:52 AM
Post #2


Master of the Universe
Group Icon

Posts: 1,298
Joined: 15-February 08
From: London, England


Are getting errors with this script. Are you aware that you have no mail function in your script to actually send an e-mail?

http://uk3.php.net/function.mail


--------------------
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jun 24 2008, 01:23 AM
Post #3


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


is that the only thing?


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
Antti
post Jun 24 2008, 01:26 AM
Post #4


Rapid Squeezer
Group Icon

Posts: 307
Joined: 15-February 08
From: Finland


E-mail sending can get hard with more advanced stuff so I highly recommend using some prebuilt library. For example:

http://www.swiftmailer.org/ or
http://phpmailer.codeworxtech.com/

OMG, I just noticed that phpmailer is updated. I thought the project was dead long time ago. Absolutely great news!


--------------------
Go to the top of the page
 
+Quote Post
Rakuli
post Jun 24 2008, 08:15 AM
Post #5


Squeeze Machine
Group Icon

Posts: 764
Joined: 13-February 08
From: Catching the squeezed drips downunder.


Your code is a bit intermingled for my liking but nothing stands out immediately as wrong (except that I cannot see where you attempt to send the mail).

Have you looked at the stickies in the PHP forum, there are 2 great examples of sending simple mail from forms.


--------------------
Luke Dingle . com

Turn Over a Playful Leaf on Web Design -- read about the javascript cat
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jun 24 2008, 12:58 PM
Post #6


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


i will take a look... thanks...


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
Justify
post Jun 24 2008, 05:37 PM
Post #7


Squeezing
***

Posts: 96
Joined: 14-February 08


Your not actually doing anything with your form.

"sendemail.php" should have a mail()

CODE
<?php

$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

?>


so grab all your variables

CODE
<?php
$aim=$_POST["$aim"]
$name=$_POST["$name"]
$number=$_POST["$number"]
?>


Then submit into the mail function

CODE
<?php
$aim=$_POST["$aim"]
$name=$_POST["$name"]
$number=$_POST["$number"] [

$to = "admin@newbreedjesusfreaks.com";
$subject = "Staff Information";
$message = "**Here would go all your layout***";  //NOTE* that you it is best to add the variables into this part rather the $_POST variables.
$from = $email;
$headers = "From: $from";

mail($to,$subject,$message,$headers);
echo "PUT HTML HERE FOR A THANKYOU FOR SUBMISSION PAGE";

?>


This should work after a while debugging your script.

Not the best way to do it. As your not checking any of the variables in form or stripping them of possible malicious input.

The ones mentioned on the forum are good examples.
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jun 24 2008, 06:55 PM
Post #8


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


So is this how my sendemail.php will look?

CODE
<?php
$Fname=$_POST["$Fname"]
$Lname=$_POST["$Lname"]
$email=$_POST["$email"]
$gender=$_POST["$gender"]
$age=$_POST["$age"]
$location=$_POST["$location"]
$christian=$_POST["$christian"]
$etc as $e=$_POST foreach["$etc as $e"]
$current=$_POST["$current"]
$whyonstaff=$_POST["$whyonstaff"]
$howcanyou=$_POST["$howcanyou"]
$howmany=$_POST["$howmany"]
$msn=$_POST["$msn"]
$yahoo=$_POST["$yahoo"]
$aim=$_POST["$aim"]
$skype=$_POST["$skype"]

$to = "admin@newbreedjesusfreaks.com";
$subject = "Staff Application";
$message = "
<b>Name:</b><br /><?php echo $_POST["$Fname"]; ["$Lname"]; ?><br />
<br />
<b>Valid E-mail Address:</b><br /><?php echo $_POST["email"]; ?><br />
<br />
<b>Gender:</b><br /><?php echo $_POST["$gender"]; ?><br />
<br />
<b>Age:</b><br /><?php echo $_POST["$age"]; ?><br />
<br />
<b>Location:</b><br /><php echo $_POST["$location"]; ?><br />
<br />
<b>Am I a Christian?</b><br /><?php echo $_POST["$christian"]; ?><br />
<b>I am:</b><br /><php echo $_POST foreach["$etc as $e"]; ?><br />
<br />
<br />
<b>How long have I been a member of NBJF?</b><br /><?php echo $_POST["$current"]; ?><br />
<br />
<b>Why I would like to be on the NBJF Staff.</b><br /><php echo $_POST["$whyonstaff"]' ?><br />
<br />
echo "<b>What/how can I contribute to NBJF?</b><br /><?php echo $_POST["$howcanyou"]; ?><br />
<br />
<b>How often I am online.</b><br /><?php echo $_POST["$howmany"]; ?><br />
<br />
<b>MSN/Windows Live Messenger:</b><br /><?php echo $_POST["$msn"]; ?><br />
<br />
<b>Yahoo Messenger:</b><br /><?php echo $_POST["$yahoo"]; ?><br />
<br />
<b>AIM:</b><br /><?php echo $_POST["$aim"]; ?><br />
<br />
<b>Skype:</b><br /><php echo $_POST["$skype"]; ?><br />
";
$from = "$_POST["Fname"]; ["Lname"]";
$headers = "From: $from";
mail($to, $subject, $message, $headers);
echo "Mail Sent.";

?>


This post has been edited by mcdanielnc89: Jun 24 2008, 07:03 PM


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jun 30 2008, 12:12 AM
Post #9


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


Bump!


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
velo
post Jul 2 2008, 02:16 PM
Post #10


Rapid Squeezer
****

Posts: 182
Joined: 19-February 08
From: Netherlands


What's up with that $message variable?
CODE
$message = "
<b>Name:</b>
<?php echo $_POST["$Fname"]; ["$Lname"]; ?>


etc..etc..

";


You can't open a php block inside a php block and set an echo statement inside a string assignment.
And why are you even using the POST there, while you are fetching the variable already on top, like the Lname. And what is that call to Lname? ["$Lname"]; ?

It would be something like:
CODE
$message = "
<b>Name:</b> {$Fname} {$Lname}


etc


";


Try changing those things first. I don't think you've done some kind of echo statement of what the output of $message would be? It couldn't have looked good. tongue.gif

Good luck!

This post has been edited by velo: Jul 2 2008, 02:17 PM


--------------------

fresh-style.nl - small webdesign & development projects
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jul 2 2008, 03:21 PM
Post #11


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


Here's the new code.. How's this look?

tis is the sendemail.php
CODE
<?php
$Fname=$_POST["$Fname"]
$Lname=$_POST["$Lname"]
$email=$_POST["$email"]
$gender=$_POST["$gender"]
$age=$_POST["$age"]
$location=$_POST["$location"]
$christian=$_POST["$christian"]
$etc as $e=$_POST foreach["$etc as $e"]
$current=$_POST["$current"]
$whyonstaff=$_POST["$whyonstaff"]
$howcanyou=$_POST["$howcanyou"]
$howmany=$_POST["$howmany"]
$msn=$_POST["$msn"]
$yahoo=$_POST["$yahoo"]
$aim=$_POST["$aim"]
$skype=$_POST["$skype"]

$to = "admin@newbreedjesusfreaks.com";
$subject = "Staff Application";
$message = "
<b>Name:</b><br /> {"$Fname"} {"$Lname"}
<br />
<br />
<b>Valid E-mail Address:</b><br />{"email"}
<br />
<br />
<b>Gender:</b><br />{"$gender"}
<br />
<br />
<b>Age:</b><br />{"$age"}
<br />
<br />
<b>Location:</b><br />{"$location"}
<br />
<br />
<b>Am I a Christian?</b><br />{"$christian"}
<br />
<br />
<b>I am:</b><br />foreach{"$etc as $e"}
<br />
<br />
<b>How long have I been a member of NBJF?</b><br />{"$current"}
<br />
<br />
<b>Why I would like to be on the NBJF Staff.</b><br />{"$whyonstaff"}
<br />
<br />
<b>What/how can I contribute to NBJF?</b><br />{"$howcanyou"}
<br />
<br />
<b>How often I am online.</b><br />{"$howmany"}
<br />
<br />
<b>MSN/Windows Live Messenger:</b><br />{"$msn"}
<br />
<br />
<b>Yahoo Messenger:</b><br />{"$yahoo"}
<br />
<br />
<b>AIM:</b><br />{"$aim"}<br />
<br />
<b>Skype:</b><br />{"$skype"}
<br />
";
$from = "$_POST["Fname"]; ["Lname"]";
$headers = "From: $from";
mail($to, $subject, $message, $headers);
echo "Mail Sent.";

?>


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
velo
post Jul 3 2008, 04:00 PM
Post #12


Rapid Squeezer
****

Posts: 182
Joined: 19-February 08
From: Netherlands


To be honest, it's no where near good. lol smile.gif
Try echo $message at bottom. It should look ridiculous. wink.gif

Why do you put " " around your variables in a string? Now you are closing the string. Normally that's not that bad, but then you have to use the php concat (dot), like

CODE
$string = "text text " . $myvar . " more text";


Either do the above, or don't put the " around your variables.

Also, you can't do a foreach inside a string assignment.
CODE
foreach{"$etc as $e"}

This really doesn't make any sense.

I think you should simply ask someone else to do it for you, or read up on it more before your next attempt. This is a lot more than debugging now. smile.gif


--------------------

fresh-style.nl - small webdesign & development projects
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jul 4 2008, 12:09 AM
Post #13


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


How's this?


Someone finsihed doing this for me..

CODE
<?php
$ip = getenv("REMOTE_ADDR");

$flag=0;

if(isset($_POST['submit'])) {

$to = "your@emailaddress.com";
$subject = "Web Inquiry";
$fname = $_POST['FName'];
$lname = $_POST['LName'];
$email_field = $_POST['email'];
$gender = $_POST['gender'];
$location=$_POST['location'];
$christian=$_POST['christian'];
$CollegeStuden=$_POST['CollegeStuden'];
$HighSchoolStudent=$_POST['HighSchoolStudent'];
$MiddleSchoolStudent=$_POST['MiddleSchoolStudent'];
$OutOfSchool=$_POST['OutOfSchool'];
$Unemployed=$_POST['Unemployed'];
$Employed=$_POST['Employed'];
$Retired=$_POST['Retired'];
$HowLongMemberOfNBJF=$_POST['HowLongMemberOfNBJF'];
$WhyOnStaff=$_POST['WhyOnStaff'];
$HowCanUContribute=$_POST['HowCanUContribute'];
$InternetAccess=$_POST['InternetAccess'];
$msn=$_POST['msn'];
$yahoo=$_POST['yahoo'];
$aim=$_POST['aim'];
$skype=$_POST['skype'];

        $body = "IP: $ip \n\n Department $department \n\n First Name: $fname:  \n\n Last name: $lname \n\n Email:$email_field \n\n Gender: $$gender \n\n Location: $location \n\n Christian: $christian \n\n CollegeStuden: $CollegeStuden\n\n HighSchoolStudent: $HighSchoolStudent \n\n MiddleSchoolStudent: $MiddleSchoolStudent \n\n OutOfSchool: $OutOfSchool  \n\n Unemployed: $Unemployed \n\n Employed: $Employed \n\n Retired: $Retired  \n\n HowLongMemberOfNBJF:  $HowLongMemberOfNBJF \n\n WhyOnStaff: $WhyOnStaff \n\n HowCanUContribute: $HowCanUContribute \n\n InternetAccess: $InternetAccess \n\n yahooo: $yahoo \n\n Skype: $skype \n\n aim: $aim\n\n";
        mail($to, $subject, $body, $email_field);
        
    }


}  

?>

<html>
<head>
<title>TITLE HERE</title>
</head>
<body>
<font size="20"><p style="text-align:center">Staff Application</p></font>

<form method="post" action="nat.php">
<br>
First Name:
<input name="FName" type="text" id="FName" size="20" maxlength="40">
<br />
Last Name:  <input name="LName" type="text" id="LName" size="20" maxlength="40">
<br />
<br />
Valid E-mail Address:<br />
<input type="text" size="50" maxlength="100" name="email"><br />
<br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender">
Female:<input type="radio" value="Female" name="gender"><br />
<br />
Age:<br />
<select name="age">
<option value="13-18">13-18</option>
<option value="19-25">19-25</option>
<option value="26-32">26-32</option>
<option value="33-41">33-41</option>
<option value="42-48">42-48</option>
<option value="49-54">49-54</option>
<option value="55-61">55-61</option>
<option value="62-68">52-68</option>
<option value="69-75">69-75</option>
<option value="76-82">76-82</option>
<option value="83+">83+</option></select>
<br />
<br />
What state/province are you in?<br />
<input type="text" size="25" maxlength="40" name="location"><br />
<br />
Are you a Christian?<br />
<select name="christian">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br />
<br />
Please check all that apply to you:<br />
<input name="CollegeStuden" type="checkbox" id="CollegeStuden" value="Yes">
College Student
<input name="HighSchoolStudent" type="checkbox" id="HighSchoolStudent" value="Yes">
High-School Student
<input name="MiddleSchoolStudent" type="checkbox" id="MiddleSchoolStudent" value="Yes">
Middle School/Jr. High Student<br />
<input name="OutOfSchool" type="checkbox" id="OutOfSchool" value="Yes">
Out of School
<input name="Unemployed" type="checkbox" id="Unemployed" value="Yes">
Unemployed
<input name="Employed" type="checkbox" id="Employed" value="Yes">
Employed<br />
<input name="Retired" type="checkbox" id="Retired" value="Yes">
Retired<br />
<br />
How long have you been a member of NBJF?<br />
<input name="HowLongMemberOfNBJF" type="text" id="HowLongMemberOfNBJF" size="25" maxlength="40">
<br />
<br />
Why do you want to be apart of the NBJF Staff?:<br />
<textarea name="WhyOnStaff" cols="40" rows="5" wrap="physical" id="WhyOnStaff"></textarea>
<br />
<br />
What/how can you contribute to NBJF?<br />
<textarea name="HowCanUContribute" cols="40" rows="5" wrap="physical" id="HowCanUContribute"></textarea>
<br />
<br />
How often do you have access to the internet?:<br />
<select name="InternetAccess" id="InternetAccess">
<option value="Less than 6 hrs. a day">Less than 6 hrs. a day</option>
<option value="2-3 times">2-3 times</option>
<option value="6+ times">6+ times</option>
<option value="Off and on throughout the day">Off and on throughout the day</option></select>:<br />
<br />
MSN/Windows Live Messenger:<br />
<input type="text" size="40" maxlength="50" name="msn"><br />
<br />
Yahoo Messenger:<br />
<input type="text" size="40" maxlength="50" name="yahoo"><br />
<br />
AIM:<br />
<input type="text" size="40" maxlength="50" name="aim"><br />
<br />
Skype:<br />
<input type="text" size="40" maxlength="50" name="skype"><br />
<br />
<input type="submit" value="Submit" name="submit"><br />
<br />
</form>


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
cosmicbdog
post Jul 4 2008, 04:24 AM
Post #14


Rapid Squeezer
****

Posts: 146
Joined: 3-July 08


Praise the lord. That looked like one heck of a mission!

I hope its working out for you.
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jul 7 2008, 09:58 PM
Post #15


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


lol... PHP isn't my thing.. I will learn it eventually but lol... I'm jsut goign to tweak it here and there for it to different things, LOL.... IF I get time.


--------------------
No Signature... No Images allowed.. :(
Go to the top of the page
 
+Quote Post
mcdanielnc89
post Jul 8 2008, 08:13 PM
Post #16


Rapid Squeezer
****

Posts: 252
Joined: 13-February 08
From: Missouri, USA


Okay everyone,

Here is the php form...

CODE
<?php
$ip = getenv("REMOTE_ADDR");

$flag=0;
$retval="";

if(isset($_POST['submit'])) {

    $to = "your@emailaddress.com";
    $subject = "Web Inquiry";
    $fname = $_POST['FName'];
    $lname = $_POST['LName'];
    $email_field = $_POST['email'];
    $gender = $_POST['gender'];
    $location=$_POST['locatio