Menu DEVPPL Search
157.820
MEMBERS
15.939
TOPICS
63.217
POSTS
  562
FLASH GAMES
7.718
TUTORIALS
 

Login

E-mail:
Password:

Mandatory Fields

0

Loading

Mandatory Fields

Postby Joshcxa » Wed Jul 27, 2005 2: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
Joshcxa
 
Reputation: 0
Posts: 156
Joined: Wed Aug 18, 2004 11:59 am
Location: Australia
Highscores: 0
Arcade winning challenges: 0

Mandatory Fields - Sponsored results

Sponsored results

Login to get rid of ads

 

0

Loading

Postby Rasmus Lindström » Wed Jul 27, 2005 2:39 pm

[php]<?php if($_POST['feildname] == "") {
echo "Your forgot to enter something in feildname";
}
?>[/php]
Last edited by Rasmus Lindström on Wed Jul 27, 2005 4:07 pm, edited 1 time in total.
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Joshcxa » Wed Jul 27, 2005 4:02 pm

cool thanks..
does that bring up an alert box?
joshcxa
DEVPPL Lightwave Moderator
Joshcxa
 
Reputation: 0
Posts: 156
Joined: Wed Aug 18, 2004 11:59 am
Location: Australia
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Rasmus Lindström » Wed Jul 27, 2005 4: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.
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Joshcxa » Thu Jul 28, 2005 2:35 am

so i can chuck javascript in the echo?
joshcxa
DEVPPL Lightwave Moderator
Joshcxa
 
Reputation: 0
Posts: 156
Joined: Wed Aug 18, 2004 11:59 am
Location: Australia
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby ReFredzRate » Thu Jul 28, 2005 5: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
 
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Rasmus Lindström » Thu Jul 28, 2005 9: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]
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Joshcxa » Thu Jul 28, 2005 1:59 pm

but the info will still send though...how do i stop that?
joshcxa
DEVPPL Lightwave Moderator
Joshcxa
 
Reputation: 0
Posts: 156
Joined: Wed Aug 18, 2004 11:59 am
Location: Australia
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Rasmus Lindström » Thu Jul 28, 2005 2: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]
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
^ Back to Top