473,545 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

validate check?

Currently, it checks to see if id is in db. If it is, it takes the
user to the survey. If not it takes the user to a page to try re-
entering code. I want to add another option. I want it to check and
see if the classid field in the db is empty if it is not empty, I want
it to go to a page saying survey has already been taken. How do I do
this? I tried a compunf if statement but it didn't work.

<?PHP
$FAIL = "surveyfailed.p hp";
$FAIL2 = "surveyfailed2. php";
$TRY = "surveyq.ph p";

if(isset($_POST['entersurvey']))
{
$id = $_POST['id'];
$class = $_POST['course'];

$sql = "SELECT * FROM $db_table10 WHERE id = '$id'";
$result = mysql_query ($sql, $connect) or die('Query 4 failed: ' .
mysql_error());
$num = mysql_num_rows( $result);

if ($num == 0)
{
echo "<meta http-equiv='Refresh' content='1;url= $FAIL'>";
}
else
{
$passid = $id;
$passcid = $class;
$_SESSION['passid'] = $passid;
$_SESSION['passcid'] = $passcid;
echo "<meta http-equiv='Refresh' content='1;url= $TRY'>";
}
}
?>
Jun 2 '08 #1
1 1141
On Thu, 15 May 2008 05:37:52 +0200, up2trouble <ly**********@g mail.com
wrote:
Currently, it checks to see if id is in db. If it is, it takes the
user to the survey. If not it takes the user to a page to try re-
entering code. I want to add another option. I want it to check and
see if the classid field in the db is empty if it is not empty, I want
it to go to a page saying survey has already been taken. How do I do
this? I tried a compunf if statement but it didn't work.

<?PHP
$FAIL = "surveyfailed.p hp";
$FAIL2 = "surveyfailed2. php";
$TRY = "surveyq.ph p";

if(isset($_POST['entersurvey']))
{
$id = $_POST['id'];
$id = isset($_POST['id']) ? mysql_real_esca pe_string($_POS T['id']) : '';
$class = $_POST['course'];
$sql = "SELECT * FROM $db_table10 WHERE id = '$id'";
$sql = "SELECT classid FROM $db_table10 WHERE id = '$id'"
$result = mysql_query ($sql, $connect) or die('Query 4 failed: ' .
mysql_error());
Don't die() with an internal error (mysql_error()) in production, provide
a nice 'something went wrong and we're sorry'-page.
$num = mysql_num_rows( $result);
if ($num == 0)
{
echo "<meta http-equiv='Refresh' content='1;url= $FAIL'>";
header() redirects are more reliable & better overall.
header('Locatio n: http://'.$_SERVER['HTTP_HOST'].'/'.$FAIL);
}
else
$row = mysql_fetch_ass oc($result);
if(empty($row['classid'])){
header('Locatio n: http://'.$_SERVER['HTTP_HOST'].'/'.$FAIL2);
exit;
} else {
$_SESSION['passid'] = $id;
$_SESSION['passcid'] = $class;
session_write_c lose();
header('Locatio n: http://'.$_SERVER['HTTP_HOST'].'/'.$TRY);
exit;
}
}
{
$passid = $id;
$passcid = $class;
$_SESSION['passid'] = $passid;
$_SESSION['passcid'] = $passcid;
echo "<meta http-equiv='Refresh' content='1;url= $TRY'>";
}
}
?>


--
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to
fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM]
Jun 2 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2521
by: Jim Heavey | last post by:
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be invoked. I am probably wrong about that. If I am suppose to use this function, the edits seemed to be invoked even when you have pressed the cancel and...
4
4274
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's the "best" way to validate prior to submitting? I could add an onsubmit attribute to the form which executes the validation in Javascript. That...
8
5391
by: tshad | last post by:
I get the following message from one of my buttons where I have CauseValidation=false. Page.IsValid cannot be called before validation has taken place In my routine I need to do: if Not IsValid then exit sub end if
24
2081
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help automate and clean up parameter validation code. It's almost ready to go into open beta. But one last little glitch is holding me up, and that would be...
24
1341
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help automate and clean up parameter validation code. It's almost ready to go into open beta. But one last little glitch is holding me up, and that would be...
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.