terrysv1
asked on
PHP A HREF not calling function with onclick
Why does this link not call the function?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
function sendmailer() {
$to = "tmiller@practicevelocity. com";
$headers = "From: GoUrgentCare.com <info@gourgentcare.com>\r\ n".
"Reply-To: donotreply@gourgentcare.co m\r\n".
"X-Mailer: PHP/" . phpversion();
$subject = "ZipPass Setup Instructions";
$body = "
1. Download
2. Setup
3. Create
";
mail($to, $subject, $body, $headers);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="#" onclick="sendmailer()">Cli ck here for instructions</a>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
function sendmailer() {
$to = "tmiller@practicevelocity.
$headers = "From: GoUrgentCare.com <info@gourgentcare.com>\r\
"Reply-To: donotreply@gourgentcare.co
"X-Mailer: PHP/" . phpversion();
$subject = "ZipPass Setup Instructions";
$body = "
1. Download
2. Setup
3. Create
";
mail($to, $subject, $body, $headers);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="#" onclick="sendmailer()">Cli
</body>
</html>
you are calling php function on javascript onclick()
because you can't call a php function from your html file.
that function is not seen by the client, so it can't be called.
it's processed by the server.
fo this
<?php
$to = "tmiller@practicevelocity. com";
$headers = "From: GoUrgentCare.com <info@gourgentcare.com>\r\ n".
"Reply-To: donotreply@gourgentcare.co m\r\n".
"X-Mailer: PHP/" . phpversion();
$subject = "ZipPass Setup Instructions";
$body = "
1. Download
2. Setup
3. Create
";
mail($to, $subject, $body, $headers);
header("location:".$_SERVE R['HTTP_RE FERER']);
?>
into it's own file without the funtion.
sendmail.php
then from html file
<a href="sendmail.php">Click here for instructions</a>
that function is not seen by the client, so it can't be called.
it's processed by the server.
fo this
<?php
$to = "tmiller@practicevelocity.
$headers = "From: GoUrgentCare.com <info@gourgentcare.com>\r\
"Reply-To: donotreply@gourgentcare.co
"X-Mailer: PHP/" . phpversion();
$subject = "ZipPass Setup Instructions";
$body = "
1. Download
2. Setup
3. Create
";
mail($to, $subject, $body, $headers);
header("location:".$_SERVE
?>
into it's own file without the funtion.
sendmail.php
then from html file
<a href="sendmail.php">Click here for instructions</a>
on click is only to call javascript, or vbscript functions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
2. form.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="submit.php">Click here for instructions</a>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="submit.php">Click here for instructions</a>
</body>
</html>
if you don't have this line in your php
header("location:".$_SERVE R['HTTP_RE FERER']);
after clicking the link, it will run the script and stay on that page. Blank.
header("location:".$_SERVE
after clicking the link, it will run the script and stay on that page. Blank.
Why did I not get an assist, since I said it first.
I said the same thing.
I said the same thing.