Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Mandatory Fields



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> HTML Forum
View previous topic :: View next topic  
Author Message
joshcxa
100+ Club


Joined: 18 Aug 2004
Posts: 156
Location: Australia

PostPosted: Wed Jul 27, 2005 2:02 pm    Post subject: Mandatory Fields Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3614
Location: Sweden

PostPosted: Wed Jul 27, 2005 2:39 pm    Post subject: Re: Mandatory Fields Reply with quote

PHP:
<?php if($_POST['feildname] == "") {
   echo "Your forgot to enter something in feildname";
}
?>


Last edited by webmaster on Wed Jul 27, 2005 4:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
joshcxa
100+ Club


Joined: 18 Aug 2004
Posts: 156
Location: Australia

PostPosted: Wed Jul 27, 2005 4:02 pm    Post subject: Re: Mandatory Fields Reply with quote

cool thanks..
does that bring up an alert box?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3614
Location: Sweden

PostPosted: Wed Jul 27, 2005 4:08 pm    Post subject: Re: Mandatory Fields Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
joshcxa
100+ Club


Joined: 18 Aug 2004
Posts: 156
Location: Australia

PostPosted: Thu Jul 28, 2005 2:35 am    Post subject: Re: Mandatory Fields Reply with quote

so i can chuck javascript in the echo?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
ReFredzRate
1000+ Club


Joined: 20 Aug 2004
Posts: 2186
Location: Netherlands

PostPosted: Thu Jul 28, 2005 5:57 am    Post subject: Re: Mandatory Fields Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3614
Location: Sweden

PostPosted: Thu Jul 28, 2005 9:16 am    Post subject: Re: Mandatory Fields Reply with quote

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
}
?>
Back to top
View user's profile Send private message Visit poster's website
joshcxa
100+ Club


Joined: 18 Aug 2004
Posts: 156
Location: Australia

PostPosted: Thu Jul 28, 2005 1:59 pm    Post subject: Re: Mandatory Fields Reply with quote

but the info will still send though...how do i stop that?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3614
Location: Sweden

PostPosted: Thu Jul 28, 2005 2:15 pm    Post subject: Re: Mandatory Fields Reply with quote

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
}
?>
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> HTML Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap