0

Just when I thought I was out of the woods on this application, I decided to block someone that simply clicks the Submit button without entering any data.

I looked up the use for "if (empty($field) == TRUE" and i was pretty certain I had it right,. I still had a few punctuation errors in there, so i corrected them and ran again. Now I'm stumped. The IF statement i what's failing. Here is the before and after code too:

$WebURL = $_POST['WebURL'];

if (empty($CoName) == TRUE || empty($Address1) == TRUE || empty($City) == TRUE || empty($State) == TRUE || empty($Phone) == TRUE || empty($Email) == TRUE ||empty($SpanCat) == TRUE || empty($EngCat) == TRUE || empty($AdSize) == TRUE || empty($BusDesc) == TRUE | empty($WelcomeMsg) == TRUE || empty($WebURL) == TRUE) 
(echo "<br>You left out some required dields. <STRONG>Record NOT added</STRONG>. Enter this record again, please";
<P align="center"><A HREF="http://www.kotw.net"><STRONG>Go Back</STRONG></A></P>							
)

// connect to the database
$dbc = mysql_connect('localhost','kotw_wdps1','D0Qy6DUuOnhZ5m9R') or die('Not connected : ' . mysql_error());

Can anyone tell me what's wrong here?

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by MichaelFL
0

1 removed () around echo
2 merged two lines,
3 changed " to '

echo "<br>You left out some required dields. <STRONG>Record NOT added</STRONG>. Enter this record again, please <P align='center'><A HREF='http://www.kotw.net'><STRONG>Go Back</STRONG></A></P> ";

Edited by urtrivedi: n/a

0

The error is because of you mixed html and php and that too you have not handled it properly...
The error is in this line.-

if (empty($CoName) == TRUE || empty($Address1) == TRUE || empty($City) == TRUE || empty($State) == TRUE || empty($Phone) == TRUE || empty($Email) == TRUE ||empty($SpanCat) == TRUE || empty($EngCat) == TRUE || empty($AdSize) == TRUE || empty($BusDesc) == TRUE | empty($WelcomeMsg) == TRUE || empty($WebURL) == TRUE) 
(echo "<br>You left out some required dields. <STRONG>Record NOT added</STRONG>. Enter this record again, please";
<P align="center"><A HREF="http://www.kotw.net"><STRONG>Go Back</STRONG></A></P>							
)

Replace this with:-

if (empty($CoName) == TRUE || empty($Address1) == TRUE || empty($City) == TRUE || empty($State) == TRUE || empty($Phone) == TRUE || empty($Email) == TRUE ||empty($SpanCat) == TRUE || empty($EngCat) == TRUE || empty($AdSize) == TRUE || empty($BusDesc) == TRUE | empty($WelcomeMsg) == TRUE || empty($WebURL) == TRUE) 
(echo "<br>You left out some required dields. <STRONG>Record NOT added</STRONG>. Enter this record again, please";

echo "<P align='center'><A HREF='http://www.kotw.net'><STRONG>Go Back</STRONG></A></P>";							
)

You must either close php tag before html code or either keep the tag inside echo
Hope it's clear

0

Another newbie error. I'm going to have to make echo my friend. Thank you very much for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.