Jump to content

empty field alert and go back


pacome

Recommended Posts

I'm working with a form. I would like to alert the user that leaves a blank field that it is obligatory. After that return him to the previous page... I tried this code but it doesn't work. I can either alert and continue to the next page, or simply return to the previous page without the alert...

 

any ideas how to do it right?

thank you...

 

This one doesn't show the popup

if (strlen($_SESSION[distribucion]) != "")

{echo "Hey got your name. ";}

else {

echo "<script type='text/javascript'>window.alert('Name is needed!')</script>";

header("Location: notam.php");

}

 

without the header(Location:...) it shows the popup, but then continues...

if (strlen($_SESSION[distribucion]) != "")

{echo "Hey got your name. ";}

else {

echo "<script type='text/javascript'>window.alert('Name is needed!')</script>";

//header("Location: notam.php");

}

 

Link to comment
https://forums.phpfreaks.com/topic/50552-empty-field-alert-and-go-back/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.