PDA

View Full Version : exec php function thru js AFTER page loads?


Sergi
29.08.2001, 18:13
Hi all,

this is intriguing me a lot. I'm totally new to php and would like to know how could i do the following. Suppose you enter a page, interact with the interfaces and as a result you have 3 variables. I want to send these variables to my mailbox and deliver a confirmation page with the 3 variables for the visitor to know everything is ok. NOTE; it's not from a form, just 3 variables.

The problem is that when i write the php function it automatically executes on page load, so i cannt control the moment thru javascript. I use something like:

<?
$ml="info@meddle.f2s.com";
$sj="Hi from meddle";
$ms="just this";
if (mail($ml,$sj,$ms)) {
print("OK");
} else {
print("NOPE");
}
?>

+which automatically sends the message on page load, not when i want. Also, i would need to be able to change the variables before sending.


Any help very apreciated.
TIA

cu

<font color=green>
Sergi: [url="http://www.meddle.f2s.com"][site][/url:ntvfn0s1un] || [url="sergi@dhtmlcentral.com"][e][/url:ntvfn0s1un]
</font id=green>

Edited by - sergi on 29 Aug 2001 4:14:43

Sergi
29.08.2001, 21:04
ok, i figured out how to roundabout it. i'm now using a hiddend form to store the vars and then send the values thru a normal submit of the form, being:

<FORM name="daform" ACTION="form.php" METHOD="POST" ENCTYPE="TEXT/PLAIN">
<input name="nom" type="text" value="">
<input name="adr" type="text" value="">
<input name="msg" type="text" value="">
<input type="submit">
</FORM>

form.php has the following code:
...
<body>
<?
$destino="sergim@icm.csic.es";
$asunto="Hi from meddle";
if (mail($destino,$asunto,$msg)) {
?>
Hi <?php echo $nom; ?>, your message has been sent to our mailbox.
A reply will be sent to your <?php echo $adr; ?> address. Meanwhile, your text was:

<?php echo $msg;
} else {
?>
There must have been a problem in the process.
<?
}
?>
</body>
...


It works very nice in mozilla092w98se but doesnt return the values in ie5.0w98se. Moreover, mozilla lets me submit the form thru a normal link with:
doIT (#)
but ie doesnt allow.

Any ideas?
TIA


<font color=green>
Sergi: [url="http://www.meddle.f2s.com"][site][/url:sanhfcpqp5] || [url="sergi@dhtmlcentral.com"][e][/url:sanhfcpqp5]
</font id=green>

Sergi
03.09.2001, 18:20
hi Tim,,
thanx a lot for the link, but i got lost in all that info. I better explained my problem in the other topic [url="http://www.dhtmlcentral.com/forums/topic.asp?TOPIC_ID=2854&FORUM_ID=9&CAT_ID=1&Topic_Title=Pease+test+one+more+time&Forum_Title=Off%2Dtopic"]here[/url:4fas2s4sq8]

I would appreciate any extra help

cu

PS. to avoid crossposting i close this topic and refer to the [url="http://www.dhtmlcentral.com/forums/topic.asp?TOPIC_ID=2854&FORUM_ID=9&CAT_ID=1&Topic_Title=Pease+test+one+more+time&Forum_Title=Off%2Dtopic"]other topic[/url:4fas2s4sq8]. sorry.


<font color=green>
Sergi: [url="http://www.meddle.f2s.com"][site][/url:4fas2s4sq8] || [url="sergi@dhtmlcentral.com"][e][/url:4fas2s4sq8]
</font id=green>