Hi guys, total noob here...
So I've been tinkering around with a html and am using php to email the subitted data to me. It's all working fine, except now I've changed the rules of the form a little and I can't seem to make it do a very simple task of converting field data to a string so that I can have it in the body of the email.
Here's the code:
<?php
//If the form is submitted
if(isset($_POST['submit'])) {
//Check to make sure that the name field is not empty
if(trim($_POST['name']) == '') {
$hasError = true;
} else {
$name = trim($_POST['name']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'mickyginger@googlemail.com'; //Put your own email address here
$subject = 'Interest from the website';
$body = $name . $email;
$headers = 'From:' .$name. '<'.$email.'>' . "rn" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?>
Which works fine and dandy, only there are other fields like 'date' and 'venue' which I want to add to the body of the email regardless of whether they have been left blank or not.
Basically I want it to do something like this:
If the form is submitted
if name is not empty
$name = trim($_POST['name']);
if email is not empty
$email = trim($_POST['name']);
if number is empty OR if not
$number = trim($_POST['number']);
if date is empty OR if not
$date = trim($_POST['date']);
if there is no error
$body = $name . $email . $number . $date
seems like it should be really simple but I've tried everything I can think of with no joy...
Question handling xml data
Hello, I have sucessfull followed this tutorialhttp://www.phpfreaks.com/tutorial/handling-xml-dataand used xpath to find the books I need, here is my codeCode: [Select]<?php// load
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mine, i grabbed it from here http://www.phpfreaks.com/tutorial/basic-paginationNow onto the
PHP Game
hy i was wondering what's the best method in order to make some automatic updates in a php gamelet's say that the user should gain 1gold each minute but the user is not logged in and the process is
ASP.NET Validation Event Cycle
Hi,I have asp button as follow:<asp:Button id="btnTest" OnClientClick="SetSomething(true);" ValidationGroup="A" OnClick="btnTest_Click" />The event flow is like this,1. OnClientClick Event is
Unable to display contents in Second Drop Down Box
Hi All, What I am trying to do is 2 dependent drop down boxes and when user selects submit button the values are to be passed to the database to run a insert query. Right now, I am stuck
php email checker
I am having alot of trouble finding info on how to do these email things. I need to do the following.Have a php file log into a email account and saves the emails as text files in a directory then
Loop column after 2 results
Hello All.Here is what I have:Client ID Company name Client ID Company nameI then need a script to echo 2 results per row then start a new row.I've tried many
Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.I need to create a dropdown list of months, where the starting month is current month and the ending month is the previous months 2
Need help making a script that moves data into acrhive table
Hi,I'm kinda new to php/mysqlAnd i wrote a simple script to store sales lead for a buisness and they are posted out into a table after they are submitted in a form. The page where you can see all your
INSERT for date range
Hi allI have the following tableCode: [Select] `date` date `day` int(2) `month` int(2) `year` int(4)If I pass a date range in PHP, such asCode: [Select]$datefrom = '2009-02-20';$dateto =