A
Anonymous
Guest
I just registered, these look like good forums, v. handy!
Im a n00bie to PHP..
I have a very simple problem, and I cant think how to solve it.. and my book (PHP and MySQL Web Development) aint helpin too much, So I was wonderin if any of you could help? :wink:
Basically, I have made a simple form and If a User hasnt filled in all the fields, and they hit Submit, I want it to not have the Proceed button in the next one, but only a "go back" button. there is 6 variables, (one doesnt need to be filled in jst to make life hard) Here is the code..
Index.php is very simple, and.. well, its html haha
<HTML><HEAD><TITLE>Custom Guitars</TITLE><BODY><BR><BR>
<FORM ACTION="/matt/form.php">
<INPUT TYPE="hidden" NAME="submitted" VALUE="1">
Name* <INPUT TYPE="text" NAME="variable1"><BR>
Address 1* <INPUT TYPE="text" NAME="variable2"><BR>
Address 2* <INPUT TYPE="text" NAME="variable3"><BR>
Address 3* <INPUT TYPE="text" NAME="variable4"><BR>
Address 4 <INPUT TYPE="text" NAME="variable5"><BR>
Post Code* <INPUT TYPE="text" NAME="variable6"><BR>
<INPUT TYPE="submit" VALUE="submit"><BR><BR>
All items marked * are Required
</BODY></HTML>
heres the bit, I need help on.
<HTML><HEAD></HEAD><BODY><BR><BR>
<?
if ($submitted) {
if ($variable1=="") {
echo "your name was not filled in<BR><BR>"; }
else {
echo "Name = $variable1 <BR><BR>"; }
if ($variable2=="") {
echo "Address 1 was not filled in<BR><BR>"; }
else {
echo "Address 1 = $variable2 <BR><BR>"; }
if ($variable3=="") {
echo "Address 2 was not filled in<BR><BR>"; }
else {
echo "Address 2 = $variable3 <BR><BR>"; }
if ($variable4=="") {
echo "Address 3 was not filled in<BR><BR>"; }
else {
echo "Address 3 = $variable4 <BR><BR>"; }
if ($variable5=="") {
echo "Address 4 = N/A <BR><BR>"; }
else {
echo "Address 4 = $variable5 <BR><BR>"; }
if ($variable6=="") {
echo "Post Code was not filled in<BR><BR>"; }
else {
echo "Post Code = $variable6 <BR><BR>"; }
}
?>
</BODY></HTML>
I guess at the bottom, I need an If( statement, but am not sure on how to do this. Variable5 isn't fully required, as you can see.
I want it to complain when any one of the var1, 2, 3, 4, and 6 are left empty..
Cheers in advance for any help you can give! (sorry its a long post!)
by the way, its not for a commercial site, or anything in case your wondering, lol... just part of some IT work, for school
Im a n00bie to PHP..
I have a very simple problem, and I cant think how to solve it.. and my book (PHP and MySQL Web Development) aint helpin too much, So I was wonderin if any of you could help? :wink:
Basically, I have made a simple form and If a User hasnt filled in all the fields, and they hit Submit, I want it to not have the Proceed button in the next one, but only a "go back" button. there is 6 variables, (one doesnt need to be filled in jst to make life hard) Here is the code..
Index.php is very simple, and.. well, its html haha
<HTML><HEAD><TITLE>Custom Guitars</TITLE><BODY><BR><BR>
<FORM ACTION="/matt/form.php">
<INPUT TYPE="hidden" NAME="submitted" VALUE="1">
Name* <INPUT TYPE="text" NAME="variable1"><BR>
Address 1* <INPUT TYPE="text" NAME="variable2"><BR>
Address 2* <INPUT TYPE="text" NAME="variable3"><BR>
Address 3* <INPUT TYPE="text" NAME="variable4"><BR>
Address 4 <INPUT TYPE="text" NAME="variable5"><BR>
Post Code* <INPUT TYPE="text" NAME="variable6"><BR>
<INPUT TYPE="submit" VALUE="submit"><BR><BR>
All items marked * are Required
</BODY></HTML>
heres the bit, I need help on.
<HTML><HEAD></HEAD><BODY><BR><BR>
<?
if ($submitted) {
if ($variable1=="") {
echo "your name was not filled in<BR><BR>"; }
else {
echo "Name = $variable1 <BR><BR>"; }
if ($variable2=="") {
echo "Address 1 was not filled in<BR><BR>"; }
else {
echo "Address 1 = $variable2 <BR><BR>"; }
if ($variable3=="") {
echo "Address 2 was not filled in<BR><BR>"; }
else {
echo "Address 2 = $variable3 <BR><BR>"; }
if ($variable4=="") {
echo "Address 3 was not filled in<BR><BR>"; }
else {
echo "Address 3 = $variable4 <BR><BR>"; }
if ($variable5=="") {
echo "Address 4 = N/A <BR><BR>"; }
else {
echo "Address 4 = $variable5 <BR><BR>"; }
if ($variable6=="") {
echo "Post Code was not filled in<BR><BR>"; }
else {
echo "Post Code = $variable6 <BR><BR>"; }
}
?>
</BODY></HTML>
I guess at the bottom, I need an If( statement, but am not sure on how to do this. Variable5 isn't fully required, as you can see.
I want it to complain when any one of the var1, 2, 3, 4, and 6 are left empty..
Cheers in advance for any help you can give! (sorry its a long post!)
by the way, its not for a commercial site, or anything in case your wondering, lol... just part of some IT work, for school