PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fredman73
Forum Newbie
Posts: 4 Joined: Tue May 28, 2002 1:46 pm
Post
by fredman73 » Tue May 28, 2002 1:46 pm
Hi, all!
I'm having a problem with this PHP script. What I need it to do is display *red* text next to unentered fields on submit AND have it redirect to a specific URL (as well as send the mail) when processed successfully instead of printing a summary of what is e-mailed.
Also, can I use this code within an HTML page so I can retain use of CSS sheets and other normal HTML components? If so, where doI place the code that would normally go between head and body tags?
View source:
http://www.omt.net/tests/formmailer3.phps
Form online:
http://www.omt.net/tests/formmailer3.php
Thanks for any help you can provide, as I am a newbie at PHP.
Cheers
gotDNS
Forum Contributor
Posts: 217 Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA
Post
by gotDNS » Tue May 28, 2002 2:40 pm
Here is how I do verification, etc. on one of my pages...
The (useful part) source of the file where the input goes on:
Code: Select all
<tr>
<td height="211" width="155" align="left" bgcolor="#006699"><img src="pix.gif" border="0" height="200" width="152" /><img src="botbar.gif" border="0" height="11" width="152" /></td>
<td bgcolor="#006699" height="211" width="*" align="left" valign="top" colspan="3" rowspan="2"><font size="2" color="#FFFFFF"><strong class="drag">Sign Up</strong></font><br />
Sign-Up for a free eSites account today and learn about how you can get your business online today.<br /><br />
* - required field.<p />
<form name="signup" action="signup.php" method="post">
* <strong>First Name:</strong> <input type="text" name="fname" size="15" maxlength="25" tabindex="1"><br />
* <strong>Last Name:</strong> <input type="text" name="lname" size="15" maxlength="25" tabindex="2"><br />
* <strong>Username:</strong> <input type="text" name="username" size="15" tabindex="3" maxlength="16"> (16 characters)<br />
* <strong>Password:</strong> <input type="password" name="password" maxlength="32" size="15" tabindex="4"><br />
* <strong>Re-Type Password:</strong> <input type="password" name="password2" maxlength="32" size="15" tabindex="5"> <br />
* <strong>E-mail:</strong> <input type="text" name="email" size="15" tabindex="6"><br />
<strong>Phone:</strong> <input type="text" name="phone" size="15" tabindex="7" maxlength="16"><br />
<strong>Gender:</strong>
<input type="radio" tabindex="8" name="gender" value="M" style="border: 0; background: none;"> Male
<input type="radio" name="gender" tabindex="9" value="F" style="border: 0; background: none;"> Female
<br />
<input type="reset" value="Reset"><input type="submit" value="Continue >">
</form>
<p />
<form action="users.php" method="post">
<strong>Current Users:</strong> <input type="password" size="13" name="pw" />
<input type="submit" value="Submit" />
</form>
</td>
</td>
<td bgcolor="#006699" height="211" width="*" align="left"></td>
</tr>
The page that it is passed to:
Code: Select all
<?php if($fname == "") { ?> <b class="ERROR">ERROR: no first name entered.</b><br /> <?php } else if($lname == "") { ?> <b class="ERROR">ERROR: no last name entered.</b><br /> <?php } else if($username == "") { ?> <b class="ERROR">ERROR: no username entered.</b><br /> <?php } else if($password == "") { ?> <b class="ERROR">ERROR: no password entered.</b><br /> <?php } else if($password2 == "") { ?> <b class="ERROR">ERROR: no verification password entered.</b><br /> <?php } else if($email == "") { ?> <b class="ERROR">ERROR: no e-mail address entered.</b><br /> <?php } ?>
<?php
if($password != "" && $password2 != "" && $password == $password2 && $fname != "" && $lname != "" && $username != "" && $email != "") {
?>
<b class="ERROR">Note:</b> Please verify that the information you are about to submit is correct. If so, press Continue. If not, please go back and edit it.<br /><br />
<form action="send_usrinfo.php" method="post">
<b>First Name:</b> <?php echo $fname; ?><input type="hidden" name="fname" value="<?php echo $fname; ?>" />
<br />
<b>Last Name:</b> <?php echo $lname; ?><input type="hidden" name="lname" value="<?php echo $lname; ?>" />
<br />
<b>Username:</b> <?php echo $username; ?><input type="hidden" name="username" value="<?php echo $username; ?>" />
<br />
<b>Password:</b> <b class="CORRECT">Verified</b><input type="hidden" name="password" value="<?php echo $password; ?>" />
<br />
<b>E-mail:</b> <?php echo $email; ?><input type="hidden" name="email" value="<?php echo $email; ?>" />
<br />
<b>Phone:</b> <?php echo $phone; ?><input type="hidden" name="phone" value="<?php echo $phone; ?>" />
<br />
<b>Gender:</b> <?php echo $gender; ?><input type="hidden" name="gender" value="<?php echo $gender; ?>" />
<p />
<input type="submit" value="Continue >" />
</form>
<?php
} else if($password != $password2) { ?>
<form action="signup.php" method="post">
<input type="hidden" name="fname" value="<?php echo $fname; ?>" />
<input type="hidden" name="lname" value="<?php echo $lname; ?>" />
<input type="hidden" name="username" value="<?php echo $username; ?>" />
<b class="ERROR">ERROR: Your Passwords did not match, please try again.</b><p />
<?php if($password != "" && $password == $password2) { ?><input type="hidden" value="<?php echo $password; ?>" name="password"><?php } else { ?><strong>Password:</strong> <input type="password" name="password" maxlength="32" size="15"><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($password2 != "" && $password == $password2) { ?><input type="hidden" value="<?php echo $password2; ?>" name="password2"><?php } else { ?><strong>Re-Type Password:</strong> <input type="password" name="password2" maxlengh="32" size="15"><br /><?php } ?>
<input type="hidden" name="email" value="<?php echo $email; ?>" />
<input type="hidden" name="phone" value="<?php echo $phone; ?>" />
<input type="hidden" name="gender" value="<?php echo $gender; ?>" />
<br /><input type="submit" value="Continue >">
</form>
<?php } else { ?>
<p />
<form action="signup.php" method="post">
<?php if($fname != "") { ?><input type="hidden" value="<?php echo $fname; ?>" name="fname" /><?php } else { ?><strong>First Name:</strong> <input type="text" value="<?php echo $fname; ?>" name="fname" maxlength="25" size="15" /><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($lname != "") { ?><input type="hidden" value="<?php echo $lname; ?>" name="lname" /><?php } else { ?><strong>Last Name:</strong> <input type="text" value="<?php echo $lname; ?>" name="lname" maxlength="25" size="15" /><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($username != "") { ?><input type="hidden" value="<?php echo $username; ?>" name="username"><?php } else { ?><strong>Username:</strong> <input type="text" value="<?php echo $username; ?>" name="username" maxlength="16" size="15"><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($password != "" && $password == $password2) { ?><input type="hidden" value="<?php echo $password; ?>" name="password"><?php } else { ?><strong>Password:</strong> <input type="password" name="password" maxlength="32" size="15"><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($password2 != "" && $password == $password2) { ?><input type="hidden" value="<?php echo $password2; ?>" name="password2"><?php } else { ?><strong>Re-Type Password:</strong> <input type="password" name="password2" maxlength="32" size="15"><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<?php if($email != "") { ?><input type="hidden" value="<?php echo $email; ?>" name="email"><?php } else { ?><strong>E-mail:</strong> <input type="text" value="<?php echo $email; ?>" name="email" maxlength="49" size="15"><br /><?php } ?>
<!-- ----------------------------------------------------------------------------- -->
<input type="hidden" value="<?php echo $phone; ?>" name="phone">
<!-- ----------------------------------------------------------------------------- -->
<input type="hidden" name="gender" value="<?php echo $gender; ?>" style="border: 0; background: none;">
<p />
<input type="submit" value="Continue >">
</form>
<?php
}
?>
That is most useful form feilds.
fredman73
Forum Newbie
Posts: 4 Joined: Tue May 28, 2002 1:46 pm
Post
by fredman73 » Tue May 28, 2002 2:46 pm
Thanks, gotDNS...
Sadly it looks like Greek to me, as I am a real newbie at PHP. If you're available to perhaps play with my code, perhaps I can provide some web space (banner-free) or something in exchange?
Cheers
fredman73
Forum Newbie
Posts: 4 Joined: Tue May 28, 2002 1:46 pm
Post
by fredman73 » Wed May 29, 2002 8:23 am
Not to seem ungrateful to my fellow forum users, but if anyone is able to give me a hand, I'd be REALLY appreciative! I'm past my deadline for getting this form fixed, so I'm a tad nervous.
I updated the PHP form as I'd like it to appear BUT when viewing it as PHP, it screws up the table & cells of the form.
http://www.omt.net/imediatouch/downloadnew.phps
Again, bnext to the form fields that aren't entered, there needs to be RED text giving an error message. There is error code in the file, but it doesn't work.
Cheers and THANK YOU!!!!!!!!!!
gotDNS
Forum Contributor
Posts: 217 Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA
Post
by gotDNS » Wed May 29, 2002 1:55 pm
hey, u need more help?
Sure, e-mail me at
bri.r.p@www.com and i'll be glad to assist you with the code.
fredman73
Forum Newbie
Posts: 4 Joined: Tue May 28, 2002 1:46 pm
Post
by fredman73 » Wed May 29, 2002 2:14 pm
Perfect-o! I just e-mailed you.
Cheers,
Fred