...

View Full Version : PHP send page/information by email



dansufc
07-03-2007, 08:18 PM
Hi,

i need help on this subject, i have a website and i have a log in system with php and mysql, that works fine however i want my registered user to be able to send me information by email, they'd fill in a text field then press send. I need this to send the whole page so that it gets their username in so people can't put a another persons user name.

heres my page http://www.dansufc.co.uk/login/login.php the username is test and the password is test

you will notice that it welcomes the user then provides a box for a "review" i would like a button below this box saying send and it would send the whole page(the hi test bit and the review) please help as i am really stuck on the matter cheers,

dansufc

wcsoft
07-03-2007, 08:38 PM
You'd just need to direct it to a page that captures the form variables. Somewhat the same way you're doing the login page.

So, you're review page would need something like the following. You'd need to put the user's name into a hidden variable.


<form method="post" action="mailit.php">
<input type="hidden" name="username" value="$username" />
Review: <text area name="review" rows="10" cols="40"></textarea>
<br />
<input type="submit" value="Submit Review" />
</form>

And then in the mailit.php script, you'd just need something like:


<?php

$body = "Review by {$_POST['username']}\n\nReview: {$_POST['review']}";
mail("youremail@yourdomain.com","Review Submission",$body);

echo "Thanks for submitting your review";

?>

dansufc
07-04-2007, 12:25 PM
thanks for you quick reply, the emailing works fine however because

<form method="post" action="mailit.php">
<input type="hidden" name="username" value="$username" />
Review: <text area name="review" rows="10" cols="40"></textarea>
<br />
<input type="submit" value="Submit Review" />
</form>

is in html when i get the email i get the email from $username and not the persons user name, any idea?

StupidRalph
07-04-2007, 01:05 PM
thanks for you quick reply, the emailing works fine however because

<form method="post" action="mailit.php">
<input type="hidden" name="username" value="$username" />
Review: <text area name="review" rows="10" cols="40"></textarea>
<br />
<input type="submit" value="Submit Review" />
</form>

is in html when i get the email i get the email from $username and not the persons user name, any idea?

Are you echoing this out in the heredoc syntax or something? You literally have "$username" written out. Take out

<input type="hidden" name="username" value="$username" />
replace with

<input type="hidden" name="username" value="<?php echo $username; ?>" />

dansufc
07-04-2007, 01:18 PM
thanks mate this has worked, would have been lost without all this help thanks alot!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum