Jump to content

Submit blank form message user to fill in, and if not found display!?


suess0r

Recommended Posts

OK,

i have pg1.php which has 3 dropdowns they can choose from with a button 'submit.' I have all of my queries running smoothly and correctly, i'm just having the following problems...

1. If they don't select anything and hit submit, it takes them to pg2.php - instead of displaying a message saying "Please select from atleast one of the following options" and not leaving the page.

2. If they do choose something and it runs the query and doesn't find anything, it doesn't say "Search Results not found..."
  ---i tried doing this if outside of my for loop
[quote]if (mysql_num_rows > 0) {

for ($i = 0; $i < mysql_num_rows($result_set); $i++)
{ -queries-}
} else {
echo 'Search Results not found...';[/quote]

*but unfortunately this kept returning Search Results not found... no matter what.*

hopefully someone can shed some light on these minor 2 problems. thanks!!  ;D
Link to comment
Share on other sites

Prior to going to your second page you can try something like:
[code]
<?php

$errMsg = "";

//get infor from dropdown

if(!empty($_POST['mydropdown'])) {
  $value1 = $_POST['mydropdown];
} else {
  $errMsg .= "You forgot to select an option";
}

if($errMsg == "") {
  // No errors continue to page 2
} else {
  // There were errors display them:
  echo $errMsg;
}

?>
[/code]

If you need more explaination I can do so :)
Link to comment
Share on other sites

hmm, thanks sharkbait but i'm not POSTing the form to pg1.php i'm sending it to pg2.php where i could check to see if !empty to say that, but is there a way for me to stay in pg1.php to check if it's set on submission and if something is set to move on to pg2 with the post?? thanks for all the help!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.