It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Mandatory Fields

Mandatory Fields

Postby joshcxa on Wed Jul 27, 2005 1:02 pm

How do I make an alert popup when a required field isn't filled in.
At the moment, info from my forms get sent even if the required fields aren't filled in.
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Wed Jul 27, 2005 1:39 pm

[php]<?php if($_POST['feildname] == "") {
echo "Your forgot to enter something in feildname";
}
?>[/php]
Last edited by webmaster on Wed Jul 27, 2005 3:07 pm, edited 1 time in total.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby joshcxa on Wed Jul 27, 2005 3:02 pm

cool thanks..
does that bring up an alert box?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Wed Jul 27, 2005 3:08 pm

No it only shows the text: You forgot to enter something in fieldname.

But just change what it should echo, you can add html code in there to.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby joshcxa on Thu Jul 28, 2005 1:35 am

so i can chuck javascript in the echo?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby ReFredzRate on Thu Jul 28, 2005 4:57 am

Yes, as far as I know the PHP will be compiled, outputting pure HTML. So if you chuck HTML/Javascript/whatever in it, it will be treated the same way as you were coding a page in plain HTML or Javascript.
ReFredzRate
1000+ Club
 

Postby webmaster on Thu Jul 28, 2005 8:16 am

And to make it even easier you can end the php, write the javascript as you want and then start the php again. Like this:

[php]<?php if($_POST['feildname] == "") { ?>
Standard HTML or Javascript here!
<?php
}
?>[/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby joshcxa on Thu Jul 28, 2005 12:59 pm

but the info will still send though...how do i stop that?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Thu Jul 28, 2005 1:15 pm

If you set the name on the submit-button to: hello

[php]<?php

if(isset($_POST['hello'])) {
if($_POST['url'] == "") { ?>
You forgot the enter something in the url-field
<?php
} elseif($_POST['mail'] == "") { ?>
You forgot the enter something in the mail-field
<?php
} else {
echo "The url is: " . $_POST['url'] . " and the mail is: " . $_POST['mail'];
}

} else { ?>

<form method......
........................
........................
</form>

<?php
}
?>[/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden


Who is online

Users browsing this forum: No registered users and 8 guests