URL with parameters/variables and auto emails ?, Lost newbie
Moderator: General Moderators
URL with parameters/variables and auto emails ?, Lost newbie
The following URL and parameters are used to return a user to my site after making a transaction:
h ttp://www.faststay.com/membersuccess.html?id= ... 3+Red+Road
So how do I use this URL and parameters to run a script that will automatically email the person (in this case george@hotmail.com) and inform him that he successfully joined my site and the password to get in is: members
Can anyone point me in the right direction ? I think php is the best for this but I have no idea how to do it. Please help if you can.
Thanks.
h ttp://www.faststay.com/membersuccess.html?id= ... 3+Red+Road
So how do I use this URL and parameters to run a script that will automatically email the person (in this case george@hotmail.com) and inform him that he successfully joined my site and the password to get in is: members
Can anyone point me in the right direction ? I think php is the best for this but I have no idea how to do it. Please help if you can.
Thanks.
The membersuccess.html page will hold the email address in a variable called '$email'.
The following code will send an email out - modify the variables as you see fit.
More information on how to make the email more pretty can be found in the php manual: [php_man]mail[/php_man]
The following code will send an email out - modify the variables as you see fit.
Code: Select all
$subject = "Welcome To Faststay.com";
$message = "Hello,
Thanks for joining.
Love,
Site Admin";
mail ($email, $subject, $message);Hi Reflexor
You need to make sure your site is PHP hosted (i.e. PHP is installed on your web server). If it is, then you need to change membersuccess.html to membersuccess.php (there is a way to run .html files as .php files if your server is an Apache one, if you know what I'm talking about and you want to do this then it's fairly easy). Changing the extension will make your server recognise your script as a PHP script and run it as one.
As for putting PHP into an HTML file, you generally do it like this:
The '?>' tag turns off PHP and back into HTML. The '<?php' tag turns PHP back on. Note that if you have a '.php' file, it is automatically assumed that all code in it is PHP by your server, and so since I have HTML at the beginning of the above script, I've turned PHP off immediately using '?>' and then back on later using '<?php'.
Hope that helps,
Mark
You need to make sure your site is PHP hosted (i.e. PHP is installed on your web server). If it is, then you need to change membersuccess.html to membersuccess.php (there is a way to run .html files as .php files if your server is an Apache one, if you know what I'm talking about and you want to do this then it's fairly easy). Changing the extension will make your server recognise your script as a PHP script and run it as one.
As for putting PHP into an HTML file, you generally do it like this:
Code: Select all
?>
<HTML>
<BODY>
<FONT FACE="Tahoma" SIZE="2">This is the HTML part of my script</FONT>
<?php
echo '<FONT FACE="Tahoma" SIZE="2">This is the PHP part of my script.</FONT>';
?>
</BODY>
</HTML>Hope that helps,
Mark
Hi Reflexor,
A PHP script can comprise of both HTML and PHP - infact it can even comprise of other languages such as JavaScript. Here's an example:
If you were to run this script on your browser, and then click 'View Source' you would just see
In other words, you have used PHP's echo command to output HTML and JavaScript to your browser. The PHP doesn't show up when you click 'View Source', because all PHP's doings occur before the pages are sent to the client (the person using a browser to look at your site). This is why PHP is called a 'server side' language (all processing occurs on your web server and is _then_ sent to the client - the client doesn't do any processing) as contrasted with a 'client side' language such as HTML (your browser interprets HTML and displays your page accordingly - hence it is a 'client side' language) and also JavaScript, which is also run by the browser.
Easy.
Mark
A PHP script can comprise of both HTML and PHP - infact it can even comprise of other languages such as JavaScript. Here's an example:
Code: Select all
echo '<A HREF="http://www.domain.com" onmouseclick="JavaScript: function();">Link Text</A>';Code: Select all
<A HREF="http://www.domain.com" onmouseclick="JavaScript: function();">Link Text</A>Easy.
Mark
http://php.net/manual/en/language.basic-syntax.php
You don't have 'to turn PHP processing off'.PHP Manual wrote: When PHP parses a file, it simply passes the text of the file through until it encounters one of the special tags which tell it to start interpreting the text as PHP code. The parser then executes all the code it finds, up until it runs into a PHP closing tag, which tells the parser to just start passing the text through again. This is the mechanism which allows you to embed PHP code inside HTML: everything outside the PHP tags is left utterly alone, while everything inside is parsed as code.
Weirdan - If I used
In my .htaccess for my server, then the PHP interpreter would be turned on for this particular file. Otherwise it would be treated as HTML and <?php ?> tags would just be treated as text. Is that not right? Otherwise PHP wouldn't be parsing the file in the first place? Pretty useful for me to know the exact answer to this question.
Mark
Code: Select all
<Files myfile.html>
ForceType application/x-httpd-php (or similar line, can't remember exactly what)
</Files>Mark