Global Variable || POST problem
Posted: Tue Jan 20, 2004 4:58 pm
Okay I'm working on "a share this article" script. It's unique because I'm dynamically passing the url from page one to page two.
This is one page one
As you can see I'm using Java Script to pass the variable to page two.
(I tried using "REFERER" on page two but I couldn't get it to work. But that's another story. If your interested I'll tell you about it)
Okay so "the Spot" is passed on to page two like this :
I know that the variable is carried over because $monkey prints on the page. Below that is this:
And Here's the mail function. My problem is that declaring globals isn't working to get the $monkey/$whatEver into the Email. I can't figure out why?
This is one page one
Code: Select all
<form action="SendArticle2.php" method="post" name="alice">
<input type="SUBMIT" value="Submit">
<script language="JavaScript">var theSpot=document.URL; document.write("<input type='hidden' name='place' value='"+theSpot+"'>"); document.write(theSpot);</script>
</form>(I tried using "REFERER" on page two but I couldn't get it to work. But that's another story. If your interested I'll tell you about it)
Okay so "the Spot" is passed on to page two like this :
Code: Select all
<?php
/* validation.php */
require_once ('functions.php');
$valid = TRUE;
$whatEver = $_POST['place'];
$monkey = $whatEver;
echo "$monkey";Code: Select all
if (isset ($_POST['submit']) {
foreach($_POST as $key=>$value) {
$$key = $value;
}
$valid = $rn = checkLength($rname, 1, 30);
$rem = checkEmail($remail);
$valid = $valid && $rem;
$sn = checkLength($sname, 1, 30);
$valid = $valid && $sn;
$sem = checkEmail($semail);
$valid = $valid && $sem;
if ($valid) {
sendArticle();
}
} else {
$rn = $sn = $sem = $rem = TRUE;
$rname = $sname = $semail = $remail;
}Code: Select all
function sendArticle(){
global $whatEver, $monkey, $rname, $remail, $sname, $semail, $comment;
$origin=$_SERVER["HTTP_REFERER"];
$Message = "Hello,\n$sname, thought you would be interested in this article at rwyouth.com \n\n $monkey \n\n Comment: $comment";
$ToSubject = "$rname, I found this great article at RWYouth.com.";
echo "<span class="boldblack">Your Email Was Sent! $monkey <br> Send Another?</span>";
echo "$monkey";
mail($rname." <".$remail.">",$ToSubject, $Message, "From: ".$sname." <".$semail.">");
}