Jump to content

elmas156

Members
  • Posts

    276
  • Joined

  • Last visited

Everything posted by elmas156

  1. Ah... so I should do this: $headers .= 'From: My Site <contact@mysite.com>' . "\r\n"; $headers .= "Reply-to: $fname $lname <$email>" . "\r\n"; Look right to you?
  2. So using the From: header, would I be able to use a variable ($email) so that it appears as though the email is coming from the user who filled out the form, or should I use a general or catch all email address on my server?
  3. OK, I've tried everything and I still can't get this to work... Here's my new code: <?php if (isset($_POST['submit'])) { // If the form has been submitted. $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $position = $_POST['position']; $district = $_POST['district']; $message = $_POST['message']; $sendto = "contact@mysite.com"; $emailsubject = "New Contact"; $emailmessage = "<html> <body> <table width='400' border='1' cellspacing='0' cellpadding='0'> <tr> <td width='150' align='left' valign='top'> Name: </td> <td width='250' align='right' valign='top'> $fname $lname </td> </tr> <tr> <td width='150' align='left' valign='top'> Email: </td> <td width='250' align='right' valign='top'> $email </td> </tr> <tr> <td width='150' align='left' valign='top'> Position/Title: </td> <td width='250' align='right' valign='top'> $position </td> </tr> <tr> <td width='150' align='left' valign='top'> District: </td> <td width='250' align='right' valign='top'> $district </td> </tr> <tr> <td width='150' align='left' valign='top'> Message: </td> <td width='250' align='right' valign='top'> </td> </tr> </table> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400' align='left' valign='top'> $message </td> </tr> </table> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= "From: $fname $lname <$email>\r\n"; // Tells the mail server who the email is from $fromaddress = "-f $email"; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers, $fromaddress); } ?> I even tried removing this line: $fromaddress = "-f $email"; I know that the mail() function is enabled on my server because I've used it with other pages, it just won't work here for some reason. Any other ideas?
  4. Can anyone see why this might not be working? I've stared at it for so long, it looks like something from the matrix now! Here's the code: <?php if (isset($_POST['submit'])) { // If the form has been submitted. $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $position = $_POST['position']; $district = $_POST['district']; $message = $_POST['message']; $sendto = "contact@mysite.com"; //this is actually supposed to go to my REAL email address... $emailsubject = "New Contact"; $emailmessage = "<html> <body> <table width='400' border='1' cellspacing='0' cellpadding='0'> <tr> <td width='150' align='left' valign='top'> Name: </td> <td width='250' align='right' valign='top'> $fname $lname </td> </tr> <tr> <td width='150' align='left' valign='top'> Email: </td> <td width='250' align='right' valign='top'> $email </td> </tr> <tr> <td width='150' align='left' valign='top'> Position/Title: </td> <td width='250' align='right' valign='top'> $position </td> </tr> <tr> <td width='150' align='left' valign='top'> District: </td> <td width='250' align='right' valign='top'> $district </td> </tr> <tr> <td width='150' align='left' valign='top'> Message: </td> <td width='250' align='right' valign='top'> </td> </tr> </table> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400' align='left' valign='top'> $message </td> </tr> </table> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: $fname $lname' . "\r\n"; // Tells the mail server who the email is from $fromaddress = '-f $email'; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers, $fromaddress); } ?> Form variables are being passed fine, it's the actual mail() portion that is giving me problems. Thanks for any help.
  5. Oh yes, now I see what's been going on... I've always used MySQL in other sites that I've done, and I've always (unknowingly ;-) used a sanitizing function, again from a tutorial that I went through on phpfreaks. So in the past, it was already being taken care of. Man, I learn something new with php every day! Thanks for your help guys.
  6. OK, thanks for your help. What do you mean by sanitizing my inputs? I did get this code snippet from some code in a tutorial on phpfreaks, but I'm not sure how or why it has worked for me for so long. I have done about 3 php sites and it has worked on all of them until this one... and I'm only using php on one page of this site, which is the contact page.
  7. This line: $message = form($_POST['message']); should set the value of whatever was entered in the "message" field of the form to be the php variable $message. If this is not the correct way to do this, I have been doing it incorrectly all along... but it has been working perfectly until now. What changes do you suggest I make?
  8. That's the thing... I'm not using "function form()". The only place on my page that you see anything about the form is where I've specified... it's just a little simplified. Here, I'll include the code for the entire page. Entire page code: <?php if (isset($_POST['submit'])) { // If the form has been submitted. $fname = form($_POST['fname']); $lname = form($_POST['lname']); $email = form($_POST['email']); $position = form($_POST['position']); $district = form($_POST['district']); $message = form($_POST['message']); $sendto = "contact@site.com"; $emailsubject = "New Contact"; $emailmessage = "<html> <body> <table width='400' border='1' cellspacing='0' cellpadding='0'> <tr> <td width='150' align='left' valign='top'> Name: </td> <td width='250' align='right' valign='top'> $fname $lname </td> </tr> <tr> <td width='150' align='left' valign='top'> Email: </td> <td width='250' align='right' valign='top'> $email </td> </tr> <tr> <td width='150' align='left' valign='top'> Position/Title: </td> <td width='250' align='right' valign='top'> $position </td> </tr> <tr> <td width='150' align='left' valign='top'> District: </td> <td width='250' align='right' valign='top'> $district </td> </tr> <tr> <td width='150' align='left' valign='top'> Message: </td> <td width='250' align='right' valign='top'> </td> </tr> </table> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400' align='left' valign='top'> $message </td> </tr> </table> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: $fname $lname' . "\r\n"; // Tells the mail server who the email is from $fromaddress = '-f $email'; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers, $fromaddress); } ?> <!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="shortcut icon" href="favicon.ico"> <link href="style.css" rel="stylesheet" type="text/css" /> <script language="JavaScript"> function validateContactForm() { var fname=document.forms["contact"]["fname"].value if (fname==null || fname=="") { alert("Please enter your first name."); return false; } var lname=document.forms["contact"]["lname"].value if (lname==null || lname=="") { alert("Please enter your last name."); return false; } var email=document.forms["contact"]["email"].value var atpos=email.indexOf("@"); var dotpos=email.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length) { alert("Please enter a valid e-mail address."); return false; } var position=document.forms["contact"]["position"].value if (position==null || position=="") { alert("Please enter your title or position you hold within the school distict you are affiliated with."); return false; } var district=document.forms["contact"]["district"].value if (district==null || district=="") { alert("Please enter the name of the school distict in which you are affiliated with."); return false; } var message=document.forms["contact"]["message"].value if (message==null || message=="") { alert("Please type your message before submitting the contact form."); return false; } } </script> <title>Contact Us</title> </head> <?php if (isset($_POST['submit'])) { echo "<body onLoad=\"alert('test')\">"; } else { echo "<body>"; } ?> <div id="container"> <div id="header"> <div id="logo_w1">Welcome<span class="sm1">SM</span></div> <div id="logo_w2">Anonymous Communication System</div> <div id="header_text"> <p>"Helping kids to safely communicate with the comfort of anonymity."</p> <a href="requestdemo.php">Request a free demo of our system.</a> </div> <ul> <li><a href="index.html">Home</a></li> <li><a href="about.html">About Us</a></li> <li><a href="service.html">Our Service</a></li> <li><a href="founder.html">Meet the Founder</a></li> <li><a href="news.html">News & Press</a></li> <li><a href="contact.php">Contact Us</a></li> </ul> </div> <div id="content"> <div id="left"> <h1>Contact Us...</h1> <p>Please provide the following information:<br /> <em>Required*</em></p> <form name="contact" method="POST" action="contact.php" onsubmit="return validateContactForm()"> <table width="470" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" align="left" valign="top"> First Name*:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="fname" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> <tr> <td width="150" align="left" valign="top"> Last Name*:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="lname" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> <tr> <td width="150" align="left" valign="top"> Email*:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="email" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> <tr> <td width="170" align="left" valign="top"> Position/Title*:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="position" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> <tr> <td width="150" align="left" valign="top"> School District*:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="district" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> <tr> <td width="150" align="left" valign="top"> Phone:<br /><img src="images/nothing.gif" height="5" /> </td> <td width="300" align="right" valign="top"> <input class="textbox" name="phone" type="text" /><br /><img src="images/nothing.gif" height="5" /> </td> </tr> </table> </div> <div id="right"> <h3>Other Contact Methods...</h3> <p><strong>Contact us via email:</strong><br /> Contact@CaresAbout.us</p> <p><strong>Or via telephone:</strong><br /> Phone1<br /> Phone2</p> <p> </p><p> </p> </div> <div id="whole"> Message*:<br /> <textarea class="textarea" name="message"></textarea><br /><img src="images/nothing.gif" height="5" /><br /> <input type="submit" name="submit" value="Send Message" /> </form> </div> <div id="footerline"></div> </div> <div id="footer"></div> </div> </body> </html>
  9. I have been trying to figure this out for hours and I can't see what's wrong. I'm getting this fatal error: Fatal error: Call to undefined function form() in /home/content/29/6879529/html/contact.php on line 5 Here's my form code: <html> <form name="contact" method="POST" action="contact.php" onsubmit="return validateContactForm()"> <input class="textbox" name="fname" type="text" /> <input type="submit" name="submit" value="Send Message" /> </form> </html> Here's my php code, which is at the top of the same page the form is on: <?php if (isset($_POST['submit'])) { // If the form has been submitted. $fname = form($_POST['fname']); //This is line 5 echo $fname; } ?> Any ideas on what could be causing this error? I've used this format MANY times in the past and I've never had a problem until now. I'm baffled!
  10. Well, I'm using Firefox 4, which is a beta version. I think it had something to do with the browser because it's not happening at all now, even if I try to make it happen. I don't think it ever happened in IE either. As far as inefficiency, I don't think that is the case. What I am doing now that I know a little more about php and how it works, I'm re-doing my entire site with the intention of making it more efficient by cleaning up my code. I've removed a lot of un-needed code and it does seem to respond faster as well. I'll see how things go and if the problem re-occurs. Thank!
  11. Great, as long as I know that it's not likely a problem with my code. As always, thanks for your help!
  12. Am I correct to put session_start at the top of every page that the user will view while signed in? That is what I've been doing, and, like I said, this warning just suddenly started showing up, and it's only an occasional warning, I can even click the browser back button and re-click the same link and it will go to the appropriate page rather than show the warning message again. It's very odd.
  13. No, none of that. In fact, I only have session_start(); on one file, which is included in the pages that are only accessible to signed in users, along with my database sign in information and a few other variables that remain the same during the session. I do, however use the following if statement to display certain information if the user is signed in: if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { show this } else { show this } This is used on a couple of files that are included on every page. Other than this, the session is not mentioned any where else on any of the pages.
  14. I'm using WampServer to test php pages locally. I just started having this warning message show up: Warning: session_start() [function.session-start]: open(c:/wamp/tmp\sess_3c3f4g0dhb6qu007v167pv1u45, O_RDWR) failed: Permission denied (13) in C:\wamp\www\page_include\index.inc.php on line 2 The warning shows up and I am directed to the login page. The funny thing is, when I refresh the browser, the warning goes away and the page is directed to the page the user is directed to after they are signed in. I haven't changed any of my code since everything was working fine. Is this a problem with WampServer or possibly something that I should be looking at changing my code to fix? Any suggestions? Thanks.
  15. Thanks very much. I'll give it a try.
  16. OK, so after the session variable is set using this line: $_SESSION['email'] = $email; I do not need to include this on any pages that user will view while they are signed in... as long as the value of $email doesn't change? So would this make more sense to include on all pages where I am using $email for other purposes: session_start(); if ($_SESSION['logged'] == 1) { $email=$_SESSION['email']; } else { header("Location: index.php"); exit(); } Of course, this is only after the session variable has been set using this line when the user logs in: $_SESSION['email'] = $email; Anyone see any potential problems with this? Thanks again for your help.
  17. I'm trying to clean up my code as best I know how and get rid of code that isn't necessary. This is where I'm most confused: On every page, I start a session and if someone goes to a page other than the index/login page, they are redirected if there is no session, otherwise, they are allowed to continue to view the page content. Here is my code: <?php session_start(); $email=$_SESSION['email']; // is this line necessary on every page... if ($_SESSION['logged'] != 1) { $_SESSION['email'] = $email; // as well as this line? header("Location: index.php"); exit(); } ?> Basically, I need to know if the SESSION['email'] has to be set on every page, or does it stay set as long is the session is logged? If it stays set for the entire session, I shouldn't need to include the "$email=$_SESSION['email'];" line on every page, right? Also, if my thinking is correct, I shouldn't need to include the "$_SESSION['email'] = $email;" line unless I need to use the $email variable for some other purpose. Am I correct on this? Thanks for any input.
  18. For this: <a href="pwordhelp.php" onMouseOver="window.name = 'main'" onClick="return pwpopup(this, 'notes')>Click</a> I tried this: echo "<a href='pwordhelp.php' onMouseOver='window.name = \'main\' ' onClick='return pwpopup(this, \'notes\')'>Click</a>"; and this: echo "<a href=\'pwordhelp.php\' onMouseOver=\'window.name = 'main'\' onClick=\'return pwpopup(this, 'notes')\'>Click</a>"; neither of them worked... oh well, guess I'm sticking with double quotes :-)
  19. Like this?: echo "<a href='popup.php' onMouseOver='window.name=\'main\'' onClick='return popup(this, \'notes\')'>Click Here</a>"; Is this correct? Or would it be like this?: echo "<a href=\'popup.php\' onMouseOver=\'window.name='main'\' onClick=\'return popup(this, 'notes')\'>Click Here</a>";
  20. how would you use the single quote method in strings that already have single quotes? For example using php and javascript the following way would not work with single quotes because you already have single quotes in the string: echo "<a href=\"popup.php\" onMouseOver=\"window.name='main'\" onClick=\"return popup(this, 'notes')\">Click Here</a>"; Any suggestions?
  21. Um... that was too easy ;-) Thanks Nightslyr.
  22. Hello everyone, This is a fairly simple question, but the explanation of the question isn't... I'll do my best. I have a site where my folders/sub-folders/files are arranged similar to this: _ Root Folder -| Root-IncludeFile1.php | Root-IncludeFile2.php | _ | Sub-Folder 1 -| Sub1-File1.php | |_Sub1-File2.php | _ | Sub-Folder 2 -| Sub2-File1.php | |_Sub2-File2.php | _ |_Sub-Folder 3 -| Sub3-IncludeFile1.php |_Sub3-IncludeFile2.php Hopefully that makes sense to everyone. Anyway, I know that to include a file that is in the root folder in file in a sub-folder, I can do this - include("../includefile1.php"); -but I'm trying to include a file that is in a sub folder in a file that is in another sub-folder. For example, I'm trying to include "Sub3-IncludeFile1.php" in "Sub-File1.php" I'm lost on this because I can't get it to work. I'm not getting any error messages except to say that the variables located in the file that should be included are not found. I've tried to do this: include("http://www.mysite.com/Sub-Folder3/Sub3-IncludeFile1.php"); and it doesn't work. Can someone please point me in the right direction? Thanks in advance for your help.
  23. Hello everyone, I have a general question about something that I've been thinking about doing but have not tried yet. It involves including entire php pages rather than a short snippet of code. Here's my situation: I've created a website that caters to many different schools, each of which is assigned a sub-domain so that they have "their own" web site instead of going to one site and then clicking a link to get to their page. Every site is identical with the exception of a few images. The way I'm currently doing things is to upload every page of code into each folder the each website. Doing it this way, I'm using a lot of disk space and each time I edit one page of code, I have to upload that page to every folder in my directory. It's not too bad with only a few folders, but as more schools use my site, it could become a nightmare! What I'm thinking about doing is to upload all my pages to the parent directory, then on each page in my folders for the sub-domains just include the corresponding page in the parent directory. I will just keep the images for each sub-domain in the corresponding folder. For example, the actual code for the index page in each of my sub-domain folders would be this: <?php include("../indexpage.inc.php"); ?> This way, I use less disk space and if I need to edit some code, I do it once, and upload it once to the parent directory, instead of having to upload it to each and every folder. Does anyone see any problem with doing this? Thanks for your opinion.
  24. great! I knew it had to be simple. Thanks!
  25. I need to make the following code work without case sensitivity. For example, if this was processed, I would like for $message to be changed from "Stupid is not a nice word. Ugly is not nice either." to "unintelligent is not a nice word. unattractive is not nice either." For my purposes, I don't care that the capitalization changes, I just need the $goodwords to be replaced with the $badwords regardless of capitalization. Any ideas here? <?php $message = "Stupid is not a nice word. Ugly is not nice either."; $badwords = array("stupid", "ugly"); $goodwords = array("unintelligent", "unattractive" ); $message = str_replace($badwords, $goodwords, $message); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.