-
Hi all...
I'm playing with a PHP script and am not very well-versed in scripting PHP.
Take a look at: http://www.omt.net/imediatouch/1.phps
What I need it to do but am having problems with is having red text display above each unentered/checked field on submit rather than at the top. It should also save inputed info so the user only has to fix what wasn't entered rather than type everything again. It should also redirect to a specific page on successful submit rather than refresh with the "click here to download" text.
If anyone can help me fix this script, I'll gladly provide some web space or something in exchange.
Note: the problem seems to lie in the following bit of code:
///
<?php
if($first_name && !$email){ echo ' <font face="Verdana" size=2 color=red><center> E-mail address is a required field </center></font>';
//destroy that name so we see the form again.
$first_name ="";
}
if(!$first_name){
if($email && !$first_name){ echo ' <font face="Verdana" size=2 color=red><center> Your name is required to send this message </center></font>'; }
echo '
///
Cheers,
Fred
fsteuart@omt.net
[Edited by fredman73 on 05-27-2002 at 03:23 PM]
-
__OSX powered__
How about:
Code:
<?php
echo "Variables test:<br>";
if(!isset($email)){
unset($first_name);
echo "Email not entered";
}
if(isset($first_name)){
echo "Everything entered";
}else{
echo "<br>Form here";
}
?>
????
-
Nucleuz,
Thanks for the bit of code. Sadly, it doesn't seem to work.
Any other suggestions?
Cheers,
Fred
-
Hi,
I usually try to do it with code similar to that
Code:
<?
function pv($name)
{ global $HTTP_POST_VARS;
if(isset($HTTP_POST_VARS[$name]))
print htmlspecialchars(stripslashes($HTTP_POST_VARS[$name]));
}
function mand($name)
{ global $HTTP_POST_VARS;
if(count($HTTP_POST_VARS) && empty($HTTP_POST_VARS[$name]))
print "<font color=red>*)</font>";
}
function checked($name)
{ global $HTTP_POST_VARS;
if(!empty($HTTP_POST_VARS[$name]))
print " checked";
?
?>
<table>
<tr><td>Name:</td><td><?mand('name');?></td><td><input type=text name=name value=\"<?pv('name');?>\"></td></tr>
<tr><td>Status:</td><td></td><td><input type=checkbox name=student<?checked('student');?>> check if you are a student</td></tr>
</table>
Musicman
-
Thanks, Musicman!
So your bit of code goes just above the form but the red text error for each field unfilled will display just above said fields? And do I leave the code ebtween the <? and ?> tags as is and edit the PHP bits next to the form elements following?
Cheers
Fred
-
Hi,
I put the code on top, and have one of those <?mand('varname')?> things wherever I want them - with my layout that is in between the field name and the field, bit you could also do a similar one
function mand($name, $message)
{ global $HTTP_POST_VARS;
if(count($HTTP_POST_VARS) && empty($HTTP_POST_VARS[$name]))
print "<font color=red>$message</font><br>";
}
and add it like here
<tr><td>Name:</td><td><?mand('name','Please enter your name');?><input type=text .... ></td></tr>
Musicman
-
Thanks, Musicman...
I sort of see what you mean. If you're feeling adventurous, would you be able to show me how that code would be used at http://www.omt.net/imediatouch/1.phps
so I know exactly how the code fits? If you'd be able to toss that code into the phps link I sent, I'd likely understand the formatting a bit better.
Thanks again!
Fred
fsteuart@omt.net
-
I just tried editing this script, which you can see at http://www.omt.net/tests/downloadtest.phps but when I try to view it as http://www.omt.net/tests/downloadtest.php it comes up with a blank page.
That, and the error text isn't in red and I need it to go to a specified URL instead of summarizing what dada was sent.
Cheers,
Fred
[Edited by fredman73 on 05-28-2002 at 12:08 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|