Dark Knight Posted January 4, 2011 Share Posted January 4, 2011 Hello everyone, and Happy New Year!I have a code for a form and a php with all the fields in it's base. See here: <?phpif (isset($_POST['sent'])){$body="Last Name: {$_POST['last-name']} \n First Name: {$_POST['first-name']} \n E-mail: {$_POST['mail']} \n Message: {$_POST['message']}";$adr="mailadress@webmailservice.com";$subject="Subject: {$_POST['subject']}";mail($adr,$subject,$body, "From: {$_POST['mail']}");header("Location: index.php"); //exit;}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Form</title></head><body><form method="post" action="index.php"><p>Last Name: <input type="text" name="last-name" size="20" /></p><p>First Name: <input type="text" name="first-name" size="20" /></p><p>Subject: <input type="text" name="subject" size="20" /></p><p>E-mail: <input type="text" name="mail" size="20" /></p><p>Message: <textarea name="message" rows="6" cols="28"></textarea></p><p><input type="submit" value="Submit" name="Send" /><input type="reset" value="Reset" name="B2" /></p></form> </body></html> Look at the code: $adr="mailadress@webmailservice.com"; How can I hide the email address? I mean not to encrypt it, but not to be shown. PS: Sorry for my bad English. Link to comment Share on other sites More sharing options...
birbal Posted January 4, 2011 Share Posted January 4, 2011 but not to be shownnot to be shown where? i cant see any output of your email..it will be no shown untill you echo it...so where is the problem you are facing? Link to comment Share on other sites More sharing options...
Dark Knight Posted January 4, 2011 Author Share Posted January 4, 2011 $adr="mailadress@webmailservice.com"; You don't know the mail because I didn't let you see it. So, in the "$adr" I can put any email address I want. Let's say I put this: $adr="darkknight@mail.com"; Now the email address will be visible to any show want to see the page source. Understand, now? Link to comment Share on other sites More sharing options...
thescientist Posted January 4, 2011 Share Posted January 4, 2011 $adr="mailadress@webmailservice.com"; You don't know the mail because I didn't let you see it. So, in the "$adr" I can put any email address I want. Let's say I put this: $adr="darkknight@mail.com"; Now the email address will be visible to any show want to see the page source. Understand, now? No, it wont. Perhaps you don't know how the interaction between PHP and HTML works? I suggest you read the PHP tutorials on the w3schools website. No one will see the email address, because as birbal points out, you are not echoing it. PHP happens behind the scenes, and is 'hidden' from browser, because the browser is not the one executing the code, the server is. Only if someone got the actual source code (not using view source) would they be able to see the email address.Quite simply, have you tried viewing the source of your own page? Link to comment Share on other sites More sharing options...
Dark Knight Posted January 5, 2011 Author Share Posted January 5, 2011 Oh, yeah! Now I understand why my PHP code was not in the Code Source of the page. It makes sense now. Thank you! Link to comment Share on other sites More sharing options...
Starfall Posted January 7, 2011 Share Posted January 7, 2011 Note that that is why people can use a config.php file to define their database information. It is not shown to the users Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.