Jump to content

elmas156

Members
  • Posts

    276
  • Joined

  • Last visited

Posts posted by elmas156

  1. It's not the HTML that isn't displaying properly, that part looks fine.  The problem comes where the actual message is displayed.  Basically, it's displaying "/r/n" everywhere there is a line break in the message.  Again, the rest of the message displays fine, it's only the line breaks in the message that I'm pulling from the database that I'm having problems displaying properly.  Thanks for your suggestion though.

  2. I have a messaging system that I'm trying to send a notification by email to a specific person when a new message is entered.  Everything is working fine except how the message is displayed in the email.  Here's the problem:

     

    When the message reads:

     

    "This is a test.

     

    This should be two lines down.

    This is on the next line!"

     

    this is what is displayed in the email:

     

    "This is a test.\r\n\r\nThis should be two lines down.\r\nThis is on the next line!"

     

    How I'm displaying the message is by inserting it into a database first.  Then I do a query to pull it back from the database on another page using the variable $message.  I have tried using just $message and using nl2br("$message") and they both display as shown above.  Does anyone have any ideas on how to get the message to display properly in the email?

     

    Here's the code that I'm using to send it in if it will help:

    <?php
    $message2 = nl2br("$message");
    $sendto2 = "$email";
    $emailsubject2 = "New Message";		
    $emailmessage2 = "<html>
    <body>
    <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
    <td>
    $prefix $lname,
    <p>
    This message is to notify you that a new message has been sent.  A copy of the message has been included below.<br>
    <hr width=\"500\"><br>
    <strong>Subject: \"$subject\"</strong>
    <p>$message2</p>
    Thank you!
    </td>
    </tr>
    </table>
    </body>
    </html>";
    
    // To send HTML mail, the Content-type header must be set
    $headers2  = 'MIME-Version: 1.0' . "\r\n";
    $headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    
    $headers2 .= 'From: Admin <support@domain.us>' . "\r\n";
    
    // Mail it
    mail($sendto2, $emailsubject2, $emailmessage2, $headers2);
    ?>
    

  3. I recently had the same problem and it was really a pain because I had written several pages incorrectly and I had to go back and basically rearrange the code to make it correct.  What you have to do is take the part of the code that is processing your sign in form, including the header that is redirecting the user to the account page, and move it all to the top of the code, before the <html> tag.  If you do this, everything should work fine.

  4. I'm trying to take a number of items from a database using a while loop and put the results into a variable so that I can send one email with all the results.  I'm having trouble figuring this out though.  Can anyone please give me any ideas as to how to make this work?  Here's what I've done so far... all it does is result in an email with the first set of results in the while loop, not all of them.

     

    <?php
    include("conf.inc.php");
    
    
    $result = mysql_query("SELECT `to`,`from`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC");
    $row = mysql_fetch_row($result);
    
    $cdate = date('m-d-Y');
    
    			$sendto = "List@emails.here";
    			$emailsubject = "Webstats Report For $cdate.";				
    
    			while ($row = mysql_fetch_row($result)) {
    
    					$to = $row[0];
    					$from = $row[1];
    					$subject = $row[2];
    					$message = $row[3];
    					$datetime = $row[4];
    
    					$eachmessage = "<p>
    					<table width=\"400\">
    					<tr>
    					<td>
    					<hr width=\"400\">
    					To: $to<br>
    					From: $from<br>
    					On $datetime<br> <br>
    					$subject<br> <br>
    					$message
    					</td>
    					</tr>
    					</table>
    					</p>";
    
    			}
    
    			$emailmessage = "<html>
    			<body>
    			<p>Here is a list of the messages that have been exchanged in the last 24 hours using the webstat system system.</p>
    			$eachmessage
    			</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: Webstats <reports@webstats.com>' . "\r\n";
    
    			// Mail it
    			mail($sendto, $emailsubject, $emailmessage, $headers);
    
    
    ?>
    

  5. OK, thanks for pointing that out.  Now I'm not getting the error message, but I'm not getting any emails sent either.  Is there a problem with the while loops that would cause a problem sending the emails?  I've never tried this before so I'm thinking there might be something wrong with the structure but I'm not sure.  Any suggestions?

  6. I'm trying to send an email that has a list created from a while loop to multiple people with an email list created from while loop.  Can someone please help me figure this out?  My brain is fried.  Here's the code that I have:

     

    This is producing an error message that reads: Parse error: syntax error, unexpected '{' in /home/content/29/6879529/html/calhoun/admin/sendreport.php on line 22

    <?php
    include("conf.inc.php");
    
    $result = mysql_query("SELECT `prefix`,`lname`,`email` FROM admin");
    $row = mysql_fetch_row($result);
    
    $result2 = mysql_query("SELECT `to`,`from`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC");
    $row2 = mysql_fetch_row($result2);
    
    $cdate = date('m-d-Y');
    
    while ($row = mysql_fetch_row($result)) {
    
    	$prefix = $row[0];
    	$lname = $row[1];
    	$adminemail = $row[2];
    	$fullname = "$prefix $lname";
    
    			$sendto = "$adminemail";
    			$emailsubject = "Webstats Report For $cdate.";				
    
    			while ($row2 = mysql_fetch_row($result2){ // This is line 22.
    
    					$to = $row2[0];
    					$from = $row[1];
    					$subject = $row[2];
    					$message = $row[3];
    					$datetime = $row[4];
    
    					$eachmessage = "<p>
    					<hr width=\"400\">
    					To: $to<br>
    					From: $from<br>
    					On $datetime<br> <br>
    					$subject<br>$nbsp;<br>
    					$message
    					</p>";
    
    			}
    
    			$emailmessage = "<html>
    			<body>
    			$fullname,
    			<p>
    			Here is a list of the messages that have been exchanged in the last 24 hours.</p>
    			$eachmessage
    			</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: Webstats <reports@webstats.com>' . "\r\n";
    
    			// Mail it
    			mail($sendto, $emailsubject, $emailmessage, $headers);
    
    }
    
    ?>
    

  7. Thanks rwwd, I would have realized that eventually ;-). 

     

    Shlumph, wouldn't this just list all the non admin people first, because the value of admin for them would be "n", then list all the admin people at the bottom without alphabetizing?  I don't know, I'm going to play with it and see what I can do... Thanks.

  8. This is the way I prefer to do it:

     

    <?php
    
    $sql = 'SELECT QuestionID, MAX(QuestionID) FROM Questions;';
    $row = mysql_fetch_row($sql)
    
    $result1 = $row[0]; // this would set the result to a variable
    
    // If you wanted to list all results of many, you would use a while loop
    

     

    Hope this helps.

  9. Hey everyone, I have a database list of staff members that work at my office.  I want to list each staff member with a while loop.  In the database there is a field named "admin" where the value is either "y" or "n."  I want to list administration first, then everyone else alphabetically by their last name.  I wrote the code below that should work (haven't tested it yet) but I'm wondering if there is an easier, more efficient way to accomplish this. Thanks for any input that you may provide.

     

    <?php
    
    $result1 = mysql_query("SELECT `prefix`,`lname`,`pos` FROM staff WHERE staffid > '0' AND admin == 'y' ORDER BY `lname` DESC");
    
    $result2 = mysql_query("SELECT `prefix`,`lname`,`pos` FROM staff WHERE staffid > '0' AND admin == 'n' ORDER BY `lname` DESC");
    
    while ($row1 = mysql_fetch_row($result1)) {
      				
    			$prefix = $row1[0];
    			$lname = $row1[1];
    			$pos = $row1[2];
    
    			$fullname1 = "$prefix $lname ($pos)";
    
                    echo "$fullname<br>";
    
    }
    
    
    while ($row2 = mysql_fetch_row($result2)) {
      				
    			$prefix = $row2[0];
    			$lname = $row2[1];
    			$pos = $row2[2];
    
    			$fullname2 = "$prefix $lname ($pos)";
    
                    echo "$fullname2<br>";
    
    }
    
    ?>
    

  10. Just a quick question about including php files on a page...

     

    Let's say I have my index page that is a fully functioning page with all the <html>, <body>, and <head> tags where they should be.  Now I want to include another file, which also has <html>, <body>, and <head> tags.  Would this cause any problems or is it ok to include the second file as is?

  11. OK, so I changed some things up and it's working now but I want to make sure that my fix isn't just a band aid fix and that I've done it the correct way.  Does this code look to be correct or do you see anything that might cause problems in the future?  Thanks for your help.

     

    <?php
    session_start(); // Starts the session.
    
    include("conf.inc.php"); // Includes the db and form info.
    if ($_SESSION['logged'] == 1) { // User is already logged in.
        $_SESSION['email'] = $email;
        header("Location: main.php"); // Goes to main page.
        exit(); // Stops the rest of the script.
    }
    
            $email = form($_POST['email']);
            $pword = md5($_POST['pword']); // Encrypts the password.
            
            $q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query
            $r = mysql_num_rows($q); // Checks to see if anything is in the db.
    
    if ($r) {    
    $_SESSION['logged'] = 1; // Sets the session.
    $_SESSION['email'] = $email;
    header("Location: main.php");
    exit();
    }
    
    ?>
    
    <html>
    
    <head>
    <title>Welcome to CaresAbout.us!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <SCRIPT TYPE="text/javascript">
    <!--
    function popup(mylink, windowname)
    {
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
    return false;
    }
    //-->
    </SCRIPT>
    
    
    <style type="text/css">
    <!--
    html { overflow: -moz-scrollbars-vertical; }
    html { overflow-x: auto; }
    
    body {
        background-color: #000000;
        background-image: url(bg.png);
        background-position: 50% 50%;
        background-repeat: repeat-y
    }
    body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
    }
    a:link {
        text-decoration: none;
    }
    a:visited {
        text-decoration: none;
    }
    a:hover {
        text-decoration: none;
    }
    a:active {
        text-decoration: none;
    }
    .bluelink {color: #0000CC}
    .blacklink {color: #000000}
    -->
    </style>
    
    </head>
    
    <body>
    
    <div align="center">
    <noscript><font size="+2" color="#000000"><strong>Some features of this site will not operate without Javascript enabled!<br>Please <a href="http://www.heart.org/HEARTORG/form/enablescript.html" class="bluelink">enable Javascript</a> in your browser to have full access.</strong></font></noscript>
      <table width="1000" height="175" border="0" cellpadding="0" cellspacing="0" style="background: transparent url('headbg.png') top center no-repeat;">
        <tr>
          <td height="125" width="160"> </td>
          <td height="125"> </td>
          <td height="125"> </td>
          <td height="125" width="160"> </td>
        </tr>
        <tr>
          <td height="50" width="160"> </td>
          
          <?php
    
        if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted.
        
            echo "<td width=\"320\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
              echo "<td width=\"360\" height=\"50\" align=\"left\" valign=\"middle\">";
            echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
            echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                  ";
            echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onMouseOver=\"window.name = 'main'\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
            echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
            echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
            echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
            echo "</form>";
            
        } else { // There is nothing in the db. The username/password do not match up.
            
            echo "<td width=\"108\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
            echo "<td width=\"572\" height=\"50\" align=\"left\" valign=\"middle\">";
            echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
            echo "                                                     <a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                 ";
            echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
            echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font>   ";
            echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
            echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
            echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
            echo "</form>";
                
        }
    
    ?>
          
          </td>
          <td height="50" width="160"> </td>
        </tr>
      </table>
    </div>
    
    <?php
    
    echo "<div align=\"center\">";
    echo "<table width=\"1000\" height=\"395\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
      echo "<tr>";
          echo "<td width=\"160\" align=\"center\" valign=\"top\">";
          // Begin Column 1.
          
          include("left.inc.php");
                
          // End Column 1.
          echo "</td>"; 
          echo "<td width=\"680\" align=\"center\" valign=\"top\" style=\"background: #FFFFFF url('bottombg.png') bottom center no-repeat;\">";
          // Begin Column 2.
    
          echo "<table width=\"650\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
            echo "<tr>";
          echo" <td align=\"left\" valign=\"top\">";
          echo "<p><img src=\"nothing.gif\" height=\"5\"><br><img src=\"silouhette.png\" height=\"215\" width=\"325\" align=\"right\"><img src=\"nothing.gif\" height=\"215\" width=\"10\" align=\"right\"><div align=\"justify\"><font size=\"+2\"> <br>Welcome students! Now you can contact the teachers and staff members of your school easily, safely, and TOTALLY ANONYMOUSLY!  Just follow these directions:</font></div></p>";
          echo "<p><font size=\"+1\">1. If you haven't already, <a href=\"signup.php\" class=\"bluelink\">sign up</a> for an account.  We will never ask for your name,<br>    all you need is an email address (get one free at <a href=\"http://www.google.com/mail\" class=\"bluelink\" target=\"_blank\">Google.com</a>).<br><img src=\"nothing.gif\" height=\"5\"><br></font>";
          echo "**  It is very important that your email address is correct because a notification will be sent to your email<br>     when you receive a message from a staff member, otherwise you will NEVER be contacted by email.<br><img src=\"nothing.gif\" height=\"10\"><br>";
          echo "<font size=\"+1\">2. Sign in to your account using your email address and password that you chose<br>    when you signed up.<br><img src=\"nothing.gif\" height=\"10\"><br>";
          echo "3. Once you are signed in, you will be able to send anonymous messages to staff<br>    members, reply to staff members' messages, and play some cool games too!</p>";
          echo "<p><div align=\"center\"><font size=\"+3\">Thank you for using CaresAbout.us!</font></p>";
          echo "</td>";
          echo "</tr>";
          echo "</table>";
          
          // End Column 2.
          echo "</td>";
          echo "<td width=\"160\" align=\"center\" valign=\"top\">";
          // Begin Column 3.
          
          include ("right.inc.php");
          
          //  End Column 3.
          echo "</td>";
      echo "</tr>";
    echo "</table>";
    echo "</div>";
    
    include("foot.inc.php");
    
    ?>
    
    </body>
    </html>
    

  12. Ok, if you've helped with any of my questions before (thanks again to those who have) you know that I'm fairly new to php and still learning.  This brings me to another question...

     

    I have read the post on header errors and I understand that in order to prevent these errors or warnings I need to  process a form BEFORE OUTPUTTING ANYTHING TO THE BROWSER.  The thing is, I'm having a problem understanding how I can do this with the code that I have written.  Can someone please look at my code and explain what is causing the header warning that I'm getting and help me to understand how to fix it?

     

    Here's my code (warning message is following the code):

    <?php
    session_start(); // Starts the session.
    ?>
    
    <html>
    
    <head>
    <title>Welcome to CaresAbout.us!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <SCRIPT TYPE="text/javascript">    <!-- THIS IS LINE 11 -->
    <!--
    function popup(mylink, windowname)
    {
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
    return false;
    }
    //-->
    </SCRIPT>
    
    
    <style type="text/css">
    <!--
    html { overflow: -moz-scrollbars-vertical; }
    html { overflow-x: auto; }
    
    body {
    background-color: #000000;
    background-image: url(bg.png);
    background-position: 50% 50%;
    background-repeat: repeat-y
    }
    body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    }
    a:link {
    text-decoration: none;
    }
    a:visited {
    text-decoration: none;
    }
    a:hover {
    text-decoration: none;
    }
    a:active {
    text-decoration: none;
    }
    .bluelink {color: #0000CC}
    .blacklink {color: #000000}
    -->
    </style>
    
    </head>
    
    <body>
    
    <div align="center">
    <noscript><font size="+2" color="#000000"><strong>Some features of this site will not operate without Javascript enabled!<br>Please <a href="http://www.heart.org/HEARTORG/form/enablescript.html" class="bluelink">enable Javascript</a> in your browser to have full access.</strong></font></noscript>
      <table width="1000" height="175" border="0" cellpadding="0" cellspacing="0" style="background: transparent url('headbg.png') top center no-repeat;">
        <tr>
      <td height="125" width="160"> </td>
      <td height="125"> </td>
      <td height="125"> </td>
      <td height="125" width="160"> </td>
    </tr>
    <tr>
      <td height="50" width="160"> </td>
      
      <?php
    
    include("conf.inc.php"); // Includes the db and form info.
    if ($_SESSION['logged'] == 1) { // User is already logged in.
        $_SESSION['email'] = $email;
    header("Location: main.php"); // Goes to main page.
    exit(); // Stops the rest of the script.
    } else {
    if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted.
    	echo "<td width=\"320\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
          	echo "<td width=\"360\" height=\"50\" align=\"left\" valign=\"middle\">";
    	echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
    	echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                  ";
    	echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onMouseOver=\"window.name = 'main'\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
    	echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
    	echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
    	echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
    	echo "</form>";
    } else {    // If the form HAS been submitted
    	$email = form($_POST['email']);
    	$pword = md5($_POST['pword']); // Encrypts the password.
    
    	$q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query
    	$r = mysql_num_rows($q); // Checks to see if anything is in the db. 
    
    	if (!$r) { // There is nothing in the db. The username/password do not match up.
    
    		echo "<td width=\"108\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
          		echo "<td width=\"572\" height=\"50\" align=\"left\" valign=\"middle\">";
    		echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
    		echo "                                                     <a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                 ";
    		echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
    		echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font>   ";
    		echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
    		echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
    		echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
    		echo "</form>";
    
    	} else {      // If the username/password is valid
    
    		$_SESSION['logged'] = 1; // Sets the session.
    		$_SESSION['email'] = $email;
    		header("Location: main.php"); // THIS IS LINE 118
    		exit(); // Stops the rest of the script.
    
    	}
    }
    }
    ?>
      
      </td>
      <td height="50" width="160"> </td>
    </tr>
      </table>
    </div>
    
    <?php
    
    echo "<div align=\"center\">";
    echo "<table width=\"1000\" height=\"395\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
      echo "<tr>";
          echo "<td width=\"160\" align=\"center\" valign=\"top\">";
      // Begin Column 1.
      
      include("left.inc.php");
      	  
      // End Column 1.
      echo "</td>"; 
          echo "<td width=\"680\" align=\"center\" valign=\"top\" style=\"background: #FFFFFF url('bottombg.png') bottom center no-repeat;\">";
      // Begin Column 2.
    
      echo "<table width=\"650\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
      	  echo "<tr>";
      echo" <td align=\"left\" valign=\"top\">";
      echo "<p><img src=\"nothing.gif\" height=\"5\"><br><img src=\"silouhette.png\" height=\"215\" width=\"325\" align=\"right\"><img src=\"nothing.gif\" height=\"215\" width=\"10\" align=\"right\"><div align=\"justify\"><font size=\"+2\"> <br>Welcome students! Now you can contact the teachers and staff members of your school easily, safely, and TOTALLY ANONYMOUSLY!  Just follow these directions:</font></div></p>";
      echo "<p><font size=\"+1\">1. If you haven't already, <a href=\"signup.php\" class=\"bluelink\">sign up</a> for an account.  We will never ask for your name,<br>    all you need is an email address (get one free at <a href=\"http://www.google.com/mail\" class=\"bluelink\" target=\"_blank\">Google.com</a>).<br><img src=\"nothing.gif\" height=\"5\"><br></font>";
      echo "**  It is very important that your email address is correct because a notification will be sent to your email<br>     when you receive a message from a staff member, otherwise you will NEVER be contacted by email.<br><img src=\"nothing.gif\" height=\"10\"><br>";
      echo "<font size=\"+1\">2. Sign in to your account using your email address and password that you chose<br>    when you signed up.<br><img src=\"nothing.gif\" height=\"10\"><br>";
      echo "3. Once you are signed in, you will be able to send anonymous messages to staff<br>    members, reply to staff members' messages, and play some cool games too!</p>";
      echo "<p><div align=\"center\"><font size=\"+3\">Thank you for using CaresAbout.us!</font></p>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      
      // End Column 2.
      echo "</td>";
      echo "<td width=\"160\" align=\"center\" valign=\"top\">";
      // Begin Column 3.
      
      include ("right.inc.php");
      
      //  End Column 3.
      echo "</td>";
      echo "</tr>";
    echo "</table>";
    echo "</div>";
    
    include("foot.inc.php");
    
    ?>
    
    </body>
    </html>
    

     

    Here's the warning message that I'm getting:

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/29/6879529/html/calhoun/index.php:11) in /home/content/29/6879529/html/calhoun/index.php on line 118

     

  13. I've got this sign in code:

     

    
    [code=php:0]
    <?php
    include("conf.inc.php"); // Includes the db and form info.
    if ($_SESSION['logged'] == 1) { // User is already logged in.
        $_SESSION['email'] = $email;
    header("Location: main.php"); // Goes to main page.
    exit(); // Stops the rest of the script.
    } else {
    if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted.
    	echo "<td width=\"320\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
          	echo "<td width=\"360\" height=\"50\" align=\"left\" valign=\"middle\">";
    	echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
    	echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                  ";
    	echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onMouseOver=\"window.name = 'main'\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
    	echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
    	echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
    	echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
    	echo "</form>";
    } else {    // If the form HAS been submitted
    	$email = form($_POST['email']);
    	$pword = md5($_POST['pword']); // Encrypts the password.
    
    	$q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query
    	$r = mysql_num_rows($q); // Checks to see if anything is in the db. 
    
    	if (!$r) { // There is nothing in the db. The username/password do not match up.
    
    		echo "<td width=\"108\" height=\"50\" align=\"left\" valign=\"middle\"> </td>";
          		echo "<td width=\"572\" height=\"50\" align=\"left\" valign=\"middle\">";
    		echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">";
    		echo "                                                     <a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a>                 ";
    		echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>";
    		echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font>   ";
    		echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\">    ";
    		echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> ";
    		echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
    		echo "</form>";
    
    	} else {      // If the username/password is invalid
    
    		$_SESSION['logged'] = 1; // Sets the session.
    		$_SESSION['email'] = $email;
    		header("Location: main.php"); //   THIS IS LINE 111
    		exit(); // Stops the rest of the script.
    
    	}
    }
    }
    ?>
    

     

    [/code]

     

    And when I sign in with my user name and password, I get this warning message:

     

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/29/6879529/html/calhoun/index.php:9) in /home/content/29/6879529/html/calhoun/head1.inc.php on line 111

     

    Can anyone help me out and tell me what I need to do to correct this?  Thanks in advance for your help!

  14. try changing this:

    <?php
    $sql2="INSERT INTO $tbl_name2(userid, password, first_name, last_name)VALUES('$userid', '$password', '$first_name', '$last_name')";
    ?>

     

     

    to this:

    <?php
    $sql2=("INSERT INTO $tbl_name2(userid, password, first_name, last_name)VALUES('$userid', '$password', '$first_name', '$last_name')"); //added open and closed parenthesis before and after the open and closed quotes...
    ?>

  15. Basically, I am recording a user's ip address when they use my site and take an action that inserts information into my database.  When I use the function as shown and use $ip where I want the ip address displayed on the screen or inserted into the database, nothing happens.  When I use the second example above and I use $ip to display or insert the ip address, everything works fine... not sure what I'm doing wrong.

  16. I have a question about functions and what is the benefit of using a function over multiple if/else statements.  For example:

     

    What would be the difference in using this function:

     

    <?php
    
    function getRealIpAddr()
    {
        if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
        {
          $ip=$_SERVER['HTTP_CLIENT_IP'];
        }
        elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
        {
          $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        }
        else
        {
          $ip=$_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
    
    ?>
    

     

    or just using this code:

     

    <?php
    
        if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
        {
          $ip=$_SERVER['HTTP_CLIENT_IP'];
        }
        elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
        {
          $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        }
        else
        {
          $ip=$_SERVER['REMOTE_ADDR'];
        }
    
    ?>
    

     

    With the first example, I try to echo the ip address ($ip) to the page and nothing happens.  With the second, I echo $ip and the ip address is shown on the page.  Why?  Am I doing something wrong or taking a shortcut that shouldn't be taken?

     

    This may seem like a silly question but I'm trying to figure this out and sometimes it's easier to just use multiple if/else statements to accomplish my task rather than an actual function.

     

    Thanks for your help.

  17. Hello, I'm pretty sure this is possible, but I have no idea where to start... I'm creating an anonymous messaging system for my school and I've had a lot of students request that they be able to send messages via sms text.  I want to find a way for the students to send a text message to some number or maybe an email address using their cell phone.  I want to have a php page that processes the message and then forwards it to a specific person depending on what the first word of the message is. 

     

    For example:

    Someone sends a message that reads: "John: This is a text message."

    I want to be able to forward the message, "This is a text message." to the user named John.

     

    Any ideas on where to start?  Is this even something that can be feasibly done?

×
×
  • 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.