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...
form problem
below in the form action, i've put "test.php?w=$sw&h=$sh" but when i input the form i get this..test.php?search=example&submit=searchhow do i get all of this together in the
Select question
Hi,First I would like to say that php is pretty new for me.. so please don't shoot me if this should be a stupid question!But I'm a little surpized due to following..I have a search script (very large
Can anyone give me some link on .htaccess tutorial
i wish to have friendly url using .htaccess, but no idea yet about this Hope that anyone could give me a simple .htaccess tutorialthanks
present value of sequence?
Hi
Generate multilayered array from string.
ok so i have a string that looks like this:Code: blog:edit_all,delete_all|users:edit_all,delete_all|settingsand i want to make a code that can take that string and put it in a multi-layered array like
Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problemi have a script that send information from a "form" but the probelm is that i need this to be
if statements problems
Hi. I'm trying to make a web form, but I kind of hit a dead end trying to figure out why it doesn't work. Basically, I'm trying to read from a file and then populate the form according to the file.The
Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of the same email. I know I need to do an IF statement but I am kinda foggy on how to do the code.What I
Display Database
I need to create a shopping cart. I found this code online: http://conceptlogic.com/jcart/Unfortunately, I dont know how to display my product from MYSQL rather than hardcoding as shown in the script
System copy error in RUN ABAP REPORT PHASE
Hi,