Jump to content

php email


Recommended Posts

This isn't working, I am just wondering if theres any errors in the code, it is just having different errorsThe form is below, that processor and validator below that.I have done this once, but now with checkboxes and radio buttons, and it's not passing through.

<form onsubmit="return submitcheckproject()" name="projectinformation" action="../cgi-bin/form-processors/projectinformationprocessor.php" method="post"><fieldset class="formstyle"><legend>Project Information</legend><br /><label for="firstname" accesskey="f">*First Name:</label><br /><input tabindex="1" name="firstname" id="firstname" type="text" maxlength="30" /><br /><label for="lastname" accesskey="l">*Last Name:</label><br /><input tabindex="2" name="lastname" id="lastname" type="text" maxlength="30" /><br /><label for="age" accesskey="2">Age:</label><br /><input tabindex="3" name="age" id="age" type="text" maxlength="3" /><br />*######:<br /><label for="male"><input name="######[]" id="male" type="radio" value="male" checked="checked" />Male</label><br /><label for="female"><input name="######[]" id="female" type="radio" value="female" />Female</label><br /><label for="operatingsystem">*Operating System</label><br /><select name="operatingsystem[]" id="operatingsystem"><option>Unix</option><option>Windows</option><option>Linux</option><option>MacOs</option><option>Other</option><option>Don't Know</option><option>Not Application</option></select><br /><label for="serverside">*Server Side</label><br /><select name="serverside" id="serverside"><option>Java Server Pages/jsp</option><option>Hypertext Preprocessor/PHP</option><option>Active Server Pages/ASP</option><option>Cold Fusion/CF</option<option>Server Side Javascript</option><option>Other</option><option>Unknown</option><option>Not Applicable</option></select><br />*Does Your website have/will have a database:<br /><label for="yes"><input name="database[]" id="yes" type="radio" />Yes</label><br /><label for="no"><input name="database[]" id="no" type="radio" checked="checked" />No</label><br /><label for="databasetype">*What database server:</label><br /><input name="databasetype" id="databasetype" type="text" maxlength="80" /><br /><label for="emailaddress" accesskey="e">*Email Address:</label><br /><input tabindex="4" name="emailaddress" id="emailaddress" type="text" maxlength="80"  /><br /><label for="verifyemail" accesskey="v">*Verify Email:</label><br /><input tabindex="5" name="verifyemail" id="verifyemail" type="text" maxlength="80" /><br /><label for="computerknowledge" accesskey="c">*How much do you know about computers in general:</label><br /><input tabindex="6" name="computerknowledge" id="computerknowledge" type="text" maxlength="80" /><br /><label for="languageknowledge" accesskey="l">*Put the computer languages you know, with your level of experience in each one:</label><br /><input tabindex="7" name="languageknowledge" id="languageknowledge" type="text" maxlength="80" /><br />*Is there a deadline associated with this project:<br /><label for="yes"><input name="deadline[]" id="yes" type="radio" value="yes" />Yes</label><br /><label for="no"><input name="deadline[]" id="no" type="radio" value="no" checked="checked" />No</label><br /><label for="timelimit">*If so what is the time limit, if not applicable, just put none:</label><br /><input tabindex="8" name="timelimit" id="timelimit" type="text" maxlength="30" /><br /><label for="projectrelation" accesskey="t">*What is the project related too:</label><br /><input name="projectrelation" id="projectrelation" type="text" maxlength="80" /><br /><label for="description" accesskey="d">*Description:</label><br /><textarea tabindex="9" name="description" id="description" rows="6" cols="30"></textarea><br /><input tabindex="10" name="submit" id="submit" type="submit" value="submit" /><input tabindex="11" name="reset" id="reset" type="reset" value="reset" /></fieldset></form>

Below is theprocessor and validater

<?phpif ($_POST['firstname'] == ""){print("Please go back and fill in the first name field correctly");}elseif ($_POST['lastname'] == ""){print("Please go back and fill in the last name field correctly");}elseif ($_POST['age'] == ""){print("Please go back and fill in the Age field");}elseif ($_POST['databasetype'] == ""){print("Please go back and fill in the Database Type Field"); }elseif ($_POST['emailaddress'] == ""){print("Please go back and fill in the Email Address field");}elseif ($_POST['verifyemail'] == ""){print("Please go back and fill in the Verify Email Address field");}elseif ($_POST['emailaddress'] != $_POST['verifyemail']){print("Your email Address fields DO NOT match, please correct this");}elseif ($_POST['computerknowledge'] == ""){print("Please go back and fill in the computer knowledge field");}elseif ($_POST['languageknowledge'] == ""){print("Please go back and fill in the Language Knowledge field");}elseif ($_POST['timelimit'] == ""){print("Please go back and fill in the Time Limit field");}elseif ($_POST['projectrelation'] == ""){print("Please go back and fill in the project relation field");}elseif ($_POST['description'] == ""){print("Please go back and fill in the Description field");}else {$firstname = $_POST['firstname'];$lastname = $_POST['lastname'];$age = $_POST['age'];$databasetype = $_POST['databasetype'];$emailaddress = $_POST['emailaddress'];$verifyemail = $_POST['verifyemail'];$computerknowledge = $_POST['computerknowledge'];$languageknowledge = $_POST['languageknowledge'];$timelimit = $_POST['timelimit'];$projectrelation = $_POST['projectrelation'];$description = $_POST['description'];$to = "businessman332211@hotmail.com";$subject = "Project Information";$message = "First Name: $firstnameLast Name: $lastnameAge:"$message .= "implode(', ',$_POST['######']);Operating System:" $message .= "implode(', ',$_POST['operatingsystem']);Server Side:" $message .= "implode(', ',$_POST['serverside']);Database Type: $databasetype";$message .= "implode(', ',$_POST['database']);Email Address: $emailaddressVerify Email: $verifyemailComputer Knowledge: $computerknowledgeLanguage Knowledge: $languageknowledge";$message .= "implode(', ',$_POST['deadline']);Time Limit: $timelimitProject Relation: $projectrelationDescription: $description";if(mail($to, $subject, $message)) {print("Thank you for submitting your email has been successfully sent");print("<br />Return to the homepage at <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");}else{print("I am sorry but there was some sort of error and the email could not be sent");print("<br />I am not totally sure of the cause of this error.");print("<br />Please return to <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");print("<br />If you try again and recieve this error message a second time, then please email me at the original email address and notify me of this error, so it can be checked into.  Thank you for visiting Freelance Businessman.");}}?>

any help would be appreciated, I have 1 hour left to work, thanks.

Link to comment
Share on other sites

Parse error: parse error, unexpected T_VARIABLE in /home/freelan4/public_html/cgi-bin/form-processors/projectinformationprocessor.php on line 51But it has multiple, I am unsure how to wire those statements into the message correctly without it coming up with messages, I don't know how to get it in there right. I have had problems with that everytime I try to do radios, or checks, then someone shows me a couple of /n here or /n there, and a couple of . . here and there they throw in a few " " here and there, and boom it works. I am unsure of all the right punctuation marks, and /n's ex cetera when trying to wire different sections into the message like that.

Link to comment
Share on other sites

<input name="######[]" id="male" type="radio" value="male" checked="checked" />
You shouldn't make the radio group an array, and I'm not sure why you're using the pound marks for the name, I assume that would probably work though. But it's probably better to just make it alpha-num. So change that to something like this:
<input name="gender" id="male" type="radio" value="male" checked="checked" /><input name="gender" id="female" type="radio" value="female" />
Your message is also formatted pretty strange. You are missing some semicolons, and you surround functions with the quotes, I don't think you want the message to say "implode(', ',$_POST['operatingsystem']);", right? You want the result of the implode function instead. And I also surrounded the variables inside the string with {}. So try changing your message to this and see if it works:
$message = "First Name: {$firstname}Last Name: {$lastname}Age: {$age}Gender: {$gender}Operating System: " . implode(', ', $_POST['operatingsystem']) . "Server Side: " . implode(', ', $_POST['serverside']) . "Database Type: {$databasetype} " . implode(', ',$_POST['database']) . "Email Address: {$emailaddress}Verify Email: {$verifyemail}Computer Knowledge: {$computerknowledge}Language Knowledge: {$languageknowledge} " . implode(', ', $_POST['deadline']) . "Time Limit: {$timelimit}Project Relation: {$projectrelation}Description: {$description}";

Link to comment
Share on other sites

Wow, they consider gender inappropriate around here? I should have realized what that was.You don't need to use {} all the time, but it is "more correct" to do so. But you only need them in a string with double-quotes (""), not single quotes (''). In fact, you don't have variables inside a string at all with single quotes. So here's an example:

$str = "some text";$str2 = "test test $str";  //$str2 is "test test some text"$str3 = 'test test $str';  //$str3 is 'test test $str'

You can include variables inside a string with double-quotes, but single-quotes will actually print the variable name itself.So you really only need {} when you are dealing with arrays. So if you have an array like $_POST, and you want to print "username", you would do it like this:echo "the user name is {$_POST['username']}";Both of these will produce the same thing, but they are less efficient and require a few lookups before they do what you expect:echo "the user name is $_POST['username']";echo "the user name is $_POST[username]";More about strings:http://www.php.net/manual/en/language.types.string.php

Link to comment
Share on other sites

If you have only a single select, where they can only select one option, then the value of the option they pick is in $_POST. So if you have this:<select name="dropdown"><option value="test">Item</option></select>There will be a variable called $_POST['dropdown'] with the value "test". You can also have a select box where people can pick multiple options if they hold down CTRL or SHIFT. In that case, it's easiest to name the select as an array (use [] at the end), and then all of the items they chose will be in the array. That looks like this:

<select name="dropdown[]" multiple="multiple" size="5"><option value="test1">Test 1</option><option value="test2">Test 2</option><option value="test3">Test 3</option><option value="test4">Test 4</option><option value="test5">Test 5</option><option value="test6">Test 6</option><option value="test7">Test 7</option><option value="test8">Test 8</option><option value="test9">Test 9</option><option value="test10">Test 10</option></select>

You reference that in PHP like this:

$dropdown = $_POST['dropdown'];foreach ($dropdown as $item){  echo "You selected {$item}<br />";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...