...

View Full Version : Perhaps I'm clicking up the wrong coding path



h8ids
06-02-2006, 09:53 PM
I have a button whose value changes upon being clicked.
Want to add a reference to a function.

The function will reside on the same page and send a HTML email.


<?php
function sendEmail(){
session_start();
//EMAIL BEGIN
$to = 'someone@somewhere.net';
$subject = 'Record Submitted';
$message = ' HTML formated email response<BR>All information submitted will be kept, ahem, confidential.<BR>
View the new record <a href=http://152.97.20.194/view.php?Records='.$Records.'>here</a> to view record.';
//MIME
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
header("Location: viewdb4.php");
}
?>


In the following code, I need to call the function sendEmail()


<input type='button' value='Submit' onclick=(value='Submitted') title='Submit for review' style='text-decoration: none' >


I have tried this:


<input type='button' value='Submit' onclick=(value='Submitted' && emailSend()) title='Submit for review' style='text-decoration: none' >


Received the following error:

missing ) in parenthetical
viewdb4.php (line 1)
(value='Submitted'

Beagle
06-02-2006, 09:58 PM
There's a separation here between server and client code. JavaScript knows nothing about PHP and PHP knows nothing about JavaScript.

So what you want is to setup something on your client that will spawn a server process to do X.

How do you do that? You have to send a request to the server from the client. Two ways of doing that: 1) navigating to a url (either in a frame or in the current window or a popup even) 2) Using XMLHTTPRequest (the famous AJAX techniques)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum