...

View Full Version : If cycle help



ggp
03-07-2007, 07:23 PM
Hi.
Could you help me plzz?
This code is not doing the cicle properly it is not going into the else to inserting the data in the db and to validate the email.
Thanks for any help



<?php
include 'global2.php';
if (isset($_POST['submit'])) {
//perform any error checking on incoming data

if (empty($name) || empty($email) || empty($subject) || empty($message)){
echo "**** .";
exit();
}

else {
if (!empty($_POST['image_id']))
{}
else
{

$date=time();

mysql_query("INSERT INTO contactus (name, email, subject, message) VALUES('{$_POST['name']}', '{$_POST['email']}' , '{$_POST['subject']}', '{$_POST['message']}')");
$message = 'Thank You for your email will be in touch with you shortly';

}

?>
<?if (isset($****)) print $****>
<?php
$from = $_REQUEST['****'];
// is the $from email address in valid format?
if(eregi("( )", $from)) {
print $name;
print $email;
print $subject;

} else {
print("Sorry, this email address: doesn't seem to be in the right format.");
}
}
}

?>

Fumigator
03-07-2007, 08:11 PM
Add error checking to your query.

ggp
03-07-2007, 09:13 PM
Sorry. I do not what could I use for error checking. Can you tell me?

Thank you.

Inigoesdr
03-07-2007, 10:16 PM
<?if (isset($****)) print $****>
That line is going to cause an error. You need to be more specific, what is not executing exactly? Are your form variables the same name as your $_POST variables? ie. <input name="submit" /> $_POST['submit']

ggp
03-07-2007, 11:29 PM
Here is what I do have in the form.
What is not executing is:
When I submit the form with all the fields it does not give me the message:
Thank You for your email will be in touch with you shortly. Also does not insert the info in the db.

Whe I submit the form with a wrong email it does not displays:
print("Sorry, this email address: doesn't seem to be in the right format.");

Thanks for any help.





<form method="post" action="eemail.php">
<table width="100%" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="20%">Name:</td>
<td width="80%"><input name="name" type="text" size=45 maxlength=80 </td>
</tr>

<tr>
<td width="20%">Email:</td>
<td width="80%"><input name="**" type="text" size=45 maxlength=80 ></td>
</tr>

<tr>
<td width="20%">Subject:</td>
<td width="80%"><input name="subject" type="text" size=45 maxlength=80 ></td>
</tr>

<tr>
<td width="20%">Message:</td>
<td width="80%"><textarea name="message" wrap="VIRTUAL" rows=5 cols=40></textarea></td>
</tr>

<tr>
<td> </td>
<td>

<input type="submit" name="submit" value="Send Email"></td>

</tr>
</table></form>




EEMAIL.PHP:



<?php
include 'global2.php';
if (isset($_POST['submit'])) {
//perform any error checking on incoming data

if (empty($name) || empty($email) || empty($subject) || empty($message)){
echo "**** .";
exit();
}

else {
if (!empty($_POST['image_id']))
{}
else
{

$date=time();

mysql_query("INSERT INTO contactus (name, email, subject, message) VALUES('{$_POST['name']}', '{$_POST['email']}' , '{$_POST['subject']}', '{$_POST['message']}')");
$message = 'Thank You for your email will be in touch with you shortly';

}

?>
<?if (isset($****)) print $****>
<?php
$from = $_REQUEST['****'];
// is the $from email address in valid format?
if(eregi("( )", $from)) {
print $name;
print $email;
print $subject;

} else {
print("Sorry, this email address: doesn't seem to be in the right format.");
}
}
}

?>

Spookster
03-07-2007, 11:31 PM
What is a cicle?

ggp
03-07-2007, 11:35 PM
Sorry. what I mean is the If{ } else{ }

Fumigator
03-07-2007, 11:45 PM
Hey Spookster don't you know it's how people are spelling cycle these days! But don't get on anyone's case about spelling, it's just "internet spelling". Nevermind the fact that we can't read it... :rolleyes:

ggp
03-08-2007, 03:50 AM
Thanks for the correction. And any help for the thread.:(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum