I have changed the message to echo '<img src="accept.gif">'; and it
displays just that - "<img src="accept.gif">". How do I get it to
display the image and not the text?
Much thanks,
Alec
echo " ?> <img src="accept.gif"> <?php";
but will most probably produce the same result.
Flamer.
echo "<img src=\"accept.gif\" />";
?>
Method 2:
<?PHP
#Heredoc version
echo <<<_text_
<img src="accept.gif" />
_text;
?>
<?php
//By Chris Campbell
//www.particletree.com
// Created April 27, 2005
//Modified June 27, 2005
//After the form is submitted or onblur, request the validation type
$validationtype = $_GET["validationtype"]; //validationtype is ajax or
php
$continueSubmit = true ; //global var if the form is valid. used only
for php validationtype.
switch ($validationtype)
{
case 'ajax':
ProcessAjax(); //if validationtype is ajax go to processajax function
break;
case 'php':
processPHP();//if it is php call processphp runction
break;
}
function ProcessAjax()
{
$required = $_GET["sRequired"];//$required holds if the field is
required. will be "required" or "notrequired"
$typecheck = $_GET["sTypeCheck"];//$typecheck holds additional
requirements like email or phone
$val = $_GET["val"];
//validateRequired checks if it is required and then sends back
feedback
validateRequired($required,$val,$typecheck);
/*check to see which typecheck (eg. email, date, etc.) was entered as
the second variable in the validateMe() function
check the different cases passed in from the validateMe function.
Send back the appropriate information*/
switch ($typecheck)
{
case 'date':
validateDate($val);
break;
case 'email':
validateEmail($val);
break;
}
}
//If the url string value for validationtype was PHP, you will be
validating through this server side function
function processPHP()
{
//request the forms variables
$user = $_POST["user"];
$email= $_POST["email"];
global $continueSubmit;
//check to see if the different form fields are valid
echo "Username: ";
validateRequired("required", $user, "none");//validate user
echo "<br />";
echo "Email: ";
validateEmail($email) ;//validate email
//if continue is not 0 then continue with the form submission
if ($continueSubmit)
{
//submit your form
}
}
//--------------------------VALIDATION FUNCTIONS -----------------
//Function to validate if the field is required. It just checks to see
if the field is empty.
function validateRequired($required,$val,$typecheck)
{
// if it is required check to see if it validates
if ($required == "required")
{
if ($val == "")
{
// if val is blank then then the field is invalid
echo "Required";
exit(); //we do not need to check for anything else so exit the
validation
}
if ($val !== "" && $typecheck == "none")
{
// if val is not blank and there are no further validation checks
("none") respond with a thank you for feedback
echo "Thank You";
}
}
// if it is not required or typecheck is not none, the script will
continue to validate
}
function validateEmail($val)
{
global $continueSubmit ;
// check the email address with a regex function
//regular expression is from http://regexlib.com/.
//To learn more about them,
http://www.silverstones.com/thebat/Regex.html#intro has a pretty good
tutorial
if (ereg
("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$",
$val, $regs))
{
echo "Thank You";
}
else
{
$continueSubmit = false;
echo "Invalid Email Address";
}
}
Thanks for your help!
Please post a link to a working example of what you're seeing or do a
"View Source" and paste the HTML source here as well. I'd like to see
exactly how the HTML on that image tag is being rendered.
Thanks!
Flamer.
if (ereg
("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$",
$val, $regs))
{
echo "Thank You";
}
did you try replacing the echo "Thank You";
with
echo "<img src=\"image.gif\">";
?
If yes, could you check what was the HTML code generated, and post it here ?
Regards,
Dragos
http://www.xmldev.ro
Here is the relevant HTML code generated (I will be removing the table
formatting once I get this working and make it CSS based):
<td><input style="background-color: rgb(255, 255, 160);"
autofillsupport="true" name="email" tabindex="2" id="email"
class="validate required email emailmsg" type="text"></td>
<td id="emailmsg" class="rules"><img src="accept.png"></td>
After I saw that it generated the character code, I changed the < and >
to < and > repectively in the php code, but that was unsuccessful
also.
My testing page for this is located at http://imageprovement.com/php/
for those who would like to see that.
Thanks for your help!
you can either.. find the expression that it is calling and rewriting
it, or stop the function from running.. either way its a job for an
advanced coder.
Flamer.
It's not the PHP that's doing it, it's the Javascript... The line that
sends the HTML results back to the tag is in this function inside
validate.js:
function handleHttpResponse() {
//if the process is completed, decide to do with the returned data
if (http.readyState == 4)
{
sResults = http.responseText.split(","); //results is now whatever
the feedback from the asp page was
//whatever the variable glo_show's (usermsg for example) innerHTML
holds, is now whatever was returned by the asp page.
document.getElementById(gShow).innerHTML = "";
//sdocument.write(sResults[0]);
document.getElementById(gShow).appendChild(document.createTextNode(sResults[0]));
}
}
This line:
document.getElementById(gShow).appendChild(document.createTextNode(sResults[0]));
can be rewritten as follows:
document.getElementById(gShow).innerHTML = sResults[0];
That should keep it from converting special characters.