Log in

View Full Version : HTML/PHP Form 2



kaos
09-07-2009, 12:01 AM
Hello everyone!

I need an error reportfor my site. the last one, made by <name here>, was almost perfect (see it here (http://www.dynamicdrive.com/forums/showthread.php?t=48000)). However, after a re-model i need something diffrent. I need a submit button that, when clicked, will send an email to me the URL of the page. This will go on hundereds unique pages so i need one that can detemin the URL by itself. If possible, I'd like it to display an alert like message before it is sent saying something like "Before submiting and error report, please close out of your browser and try again.......". Can any one help me?

traq
09-07-2009, 02:38 AM
How does JShor's solution (per your link) not work for you? What, exactly, do you need done differently?

kaos
09-07-2009, 03:49 AM
not sure exactly... the solution was made to send the url source of an iframe. i'm no longer using an iframe; i need one that will work with a unique page.

traq
09-07-2009, 07:42 AM
So your script is going to actually reside on the page that it reports? Use JShor's solution (minus the javascript) and replace the "message" value with the current page url, like so:


<?php

if(isset($_POST['submit'])) {

$to = "someone@example.com";
$subject = "Page source";
$message = $_SERVER['SCRIPT_FILENAME'];
$from = "someonelse@example.com";
$headers = "From: $from";

mail($to,$subject,$message,$headers);

echo "Mail successfully sent";

}

?>

<iframe src="blah blah" id="sourceFrame"></iframe>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="hidden" value="hidden">
<input type="submit" name="submit" value="Send Mail!">
</form>

kaos
09-07-2009, 05:52 PM
Thanks for the hep. but is there a way to send the pages url instead of the file name?

kaos
09-07-2009, 06:00 PM
One more thing, does the file have to be a PHP file? I was currently using the form action="file.php" to send it, but it sends me the php file's url. can it sendmethe prevoiuse pages' URL?