displaying error on page
Moderator: General Moderators
displaying error on page
Hi there,
got a quick question im sure it is an easy one for everyone, 'except me' !
echo ' verification is incorrect'
that code right there , how do i get it to display in a specific place on my page?
instead of the top of my include page?
Thanks,
Elaine
got a quick question im sure it is an easy one for everyone, 'except me' !
echo ' verification is incorrect'
that code right there , how do i get it to display in a specific place on my page?
instead of the top of my include page?
Thanks,
Elaine
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
Depends on your logic. Can you show some of your code and where you want to echo.
Re: displaying error on page
ok, here it all is, where it says include , it goes back to the page, and lets the person enter the information again , but i really dont want that to happen i really dont like pop up boxes, so i want it just to display the error message next to the verification code that was typed in wrong. instead of refreshing the whole page.....
Code: Select all
<?
session_start();
$msg = "Incorrect Verification Code, Please try again!";
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo "<script langauge=\"javascript\">alert(\"".$msg."\");</script>";
include 'recruiter.php';
exit;
} else {
$my_email = "elainenemeth@hotmail.com";
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = stripslashes("Name: " . $from . "\n\n" . "Email: " . $_POST['email'] . "\n\nOther: ". $_POST['other'] . "\n\n" . "Phone: " . $_POST['phone']);
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Send the message
mail($my_email, $subject, $message, $headers);
echo '';
};
?>
<?php include 'header.php';?><br>
<p align="center"><strong><font face="Arial"><big>Thank you for submitting information<br>
You will be redirected shortly</big></font></strong></p>
<script>
var redirecturl="index.php"
var pausefor=5
function postaction(){
if (window.timer){
clearInterval(timer)
clearInterval(timer_2)
}
window.location=redirecturl
}
setTimeout("postaction()",pausefor*1000)
</script>
<br><br><br><br><br><br>
<img src="images/progressbar.gif"><br><br><br><br>
<?php include 'footer.php';?>
Re: displaying error on page
any one have any ideas on how to display the error on the same page without refreshing the page ?
Thx,
Elaine
Thx,
Elaine
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
Call the validation before you call the form.
Re: displaying error on page
i dont want to have people click submit to verify the code , then submit to send the information, i just want the error 'incorrect code' to display next to it , instead of on a pop up box and not let them continue until they get it right.... possible?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
I meant if you literally place the validation code before the other code the "check if submit" clause --- if(isset($_POST['submit']) --- will enable validation only if they submit the form.
Is that clear?
Is that clear?
Re: displaying error on page
it should be, but it isnt, i dont no where to put it,

- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
So what you're doing is submitting data from one page to another, yeah?
Re: displaying error on page
No i am letting people apply to be a recruiter , or apply for jobs
go see: its not finish
http://middlemancan.bmtwebdesign.com/recruiter.php
its a simple form that people can upload there resume, but i had problems when i first put it up, alot of spam, so i implemented the image verification thingy, and now when you put in a wrong code let say it gives a pop up that says its wrong, and to try again, but i really dont like the pop up i would rather the error telling them it is wrong, goes next to the box where they entered the verification code instead...
thats it
Elaine
thank you for helping me
go see: its not finish
http://middlemancan.bmtwebdesign.com/recruiter.php
its a simple form that people can upload there resume, but i had problems when i first put it up, alot of spam, so i implemented the image verification thingy, and now when you put in a wrong code let say it gives a pop up that says its wrong, and to try again, but i really dont like the pop up i would rather the error telling them it is wrong, goes next to the box where they entered the verification code instead...
thats it
Elaine
thank you for helping me
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
It looks like you embedded javascript is not working.
What i would do is:
inside recruiter.php near the code box:
One of the main reasons why I would do it this way is because when you rely on javascript to catch an error you are assuming that the user has javascript enabled. The method I used is executed on the server so it will always catch the error - javascript is client-side.
What i would do is:
Code: Select all
$vercodeErr=0;
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
$vercodeErr=1;
include 'recruiter.php';
exit;
Code: Select all
if($vercodeErr==1){
echo $msg;
}
Re: displaying error on page
and the first part i put it in the submit.php file?
i tried it , but im not an expert i think i copied it all wrong,
where does it show the error?
i tried it , but im not an expert i think i copied it all wrong,
where does it show the error?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
This is how I usually do it:
In the validation script check the verification code:
So basically what you will be doing is:
1. calling the validation script
2. in the validation script you will check whether any data has been submitted
- if so then check code and set error variable if code is invalid
3. display the form
4. if error=1 then display error
- else process data
Hope it makes sense
Code: Select all
//call the script that carries out the validation
include"validation.php"; //this is where the error will be determined, and then displayed below if error exists
//form details - name textbox etc...
echo'<td width="21%" align="right" height="1"><font size="2" face="Arial">Image Verification:</font></td>
<td width="48%" height="1">';
//display error if code does not match
if($vercodeErr==1){
echo $msg . '<br />';
}
echo'<input type="text" name="vercode" /> <img src="captcha.php">
</td>';
Code: Select all
$vercodeErr=0;
if(isset($_POST['send']))
{
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
$vercodeErr=1;
}
}
1. calling the validation script
2. in the validation script you will check whether any data has been submitted
- if so then check code and set error variable if code is invalid
3. display the form
4. if error=1 then display error
- else process data
Hope it makes sense
Re: displaying error on page
Thank you ohh so much
makes good sense thank you for taking the time
*hugs*
Elaine
makes good sense thank you for taking the time
*hugs*
Elaine
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: displaying error on page
No probs, let me know if you get stuck 