Jump to content

kyme

Members
  • Posts

    28
  • Joined

  • Last visited

Posts posted by kyme

  1. I'm trying to display a data from DB using mysqli.

    I'm not sure if I'm doing it right, my concern was secure. Am I doing it right?

    <?php
    include_once('user.php');
    
    // Inialize session
    session_start();
    
    $con=mysqli_connect("localhost","root","root","dbname");
    if (mysqli_connect_errno())
    {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    
    $result = mysqli_query($con,"SELECT aboutme FROM testing where id=1");
    
    if ($result) {
        if ($row = mysqli_fetch_array($result, MYSQL_ASSOC))
        {
            $aboutme = $row['aboutme'];
        }
    }  
    
    mysqli_close($con);
    ?>
    
  2. Ok im sory  :-[

     

    This is my html form.

        <table clas="rink_form">
       <form method="post" action="form_survey.php">
         <tr>
          <td>
             Rink Name:  <input name="RinkName" type="text" class="form_text"> 
             Rink Address: <input name="RinkAdress" type="text" class="form_text">
          </td> 
         </tr>
         
        <td>Enter code below:</td>
       <td><img src="secimg.php"></td>
       </tr>
       <tr>
        <td> </td>
       <td><input type="text" name="Spam Code" size="8" /></td>
      </tr>
    
       <tr>
         <td colspan="2" align="center"><input type="submit" value="Submit Form">
           </td>
       </tr>
       
       </form>
       </table>   
    

       

      And my script

     

         <?php
    function checkEmpty($names, $data) {
       $n = count($names);
       $emptys = array();
       for ($i = 0; $i < $n; $i++) {
          if (empty($data[$names[$i]])) $emptys[] = $names[$i];
       }
       return $emptys;
    }
    
    function createUList($arr) {
    $n = count($arr);
    echo '<ul>';
    for ($i = 0; $i < $n; $i++)
      echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";
    echo '</ul>';
    }
    
    // needed so we can retrieve security code
    session_start();
    
    //This command imports the values from contact.php. Please do not touch.
    @import_request_variables("gpc");
    
    //The email address the message will be sent to
    $youremail = "mymail@yahoo.com";
    
    //The subject of the email you will receive;
    $subject = "Ice Rink Supply - Survey Assessment Form";
    
    //The page your visitor will be redirected to.
    $redirect = "http://www.google.com";
    
    //Time until the page redirects your visitor (seconds)
    $secs = "5";
    
    //This takes all of the information from the form and sorts it out. Please leave as is.
    
    $name= $FONT_SIZE;
    
    $FONT_SIZE=14;
    $thetext=$thetext."<html><body>\n";
    foreach ($_POST as $name => $value)
    {
    $name = str_replace('_',' ',$name);
    $thetext=$thetext."$name : <b>$value</b>\n<br/>";
    }
    $thetext=$thetext."</body></html>";
    ?>
    
    <html>
        <head> </head>
       <body>
          <?php
    
    //Checks to see if the name field is empty. You can delete or add fields as needed.
    
    // fill $infoToCheck with info that NEEDS to be filled. Spam_Code is always needed here
    $infoToCheck = array("RinkAdress");
    $emptyFlds = checkEmpty($infoToCheck,$_POST);
    $validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];
    // to make displaying invalid spam code msg easier
    if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";
    $noEmptyFlds = count($emptyFlds) == 0;
    
    if ($noEmptyFlds && $validSecurityCode)
    {
    unset($_SESSION['key']); // prevent multiple send
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    /* <--  the ff. lines are optional
    $headers .= "From: ".$myname."
    <".$myemail.">\r\n";
    $headers .= "To:  <".$email.">\r\n";
    $headers .= "Reply-To: ".$myname."
    <$myemail>\r\n";
    $headers .= "X-Priority: 1\r\n";
    $headers .= "X-MSMail-Priority: High\r\n";
    $headers .= "X-Mailer: Just My Server";
    */ 
      $name = stripslashes($name);
      $message = stripslashes($message);
    //This is where the email is sent using your values from above.
      mail($youremail,$subject,$thetext,$headers);
    ?>
    
    <meta http-equiv="refresh" content="<?=$secs;?>;URL=<?=$redirect;?>">
    <font size="+1">
    <p align="center" class="prod_h1" style="color:#FFFFFF" >Thank you, we have recieved your Assessment Form.</p>
    <p class="rink_form" align="center" style="color:#FFFFFF">
    You are now being redirected to our <a href="<?=$redirect;?>" style="color:#00CCFF">homepage</a>.
    </font>
    <?
    }
    else
    {
    ?>
    <font size="+1">
    We require the ff. in order to reply to your message: <br/> </font>
    <?php
    if (!$noEmptyFlds) createUList($emptyFlds);
    ?>
    <center>
    <font color="#FFFFFF" size="+1">
    Please click <a href="javascript:history.back(1);" style="color:#00CCFF">here</a> or your browsers back button to try again.
    </font> <br/> <br/>
    </center>
    <?
    }
    
    ?>
              
       </body>
    </html>
      

          :-[  Is there something that i mess up?  :-[

  3.   Once i fill up a form it not will read & test if the form was been fill in up

      suppose to be once it corrects it will send through mail php script.

      Why it does not read the name="RinkName" this

      Rink Name:  <input name="RinkName" type="text" class="form_text"> 

     

    Which is my script

     

     

      <?php

    function checkEmpty($names, $data) {

    $n = count($names);

    $emptys = array();

    for ($i = 0; $i < $n; $i++) {

    if (empty($data[$names[$i]])) $emptys[] = $names[$i];

    }

    return $emptys;

    }

     

    function createUList($arr) {

    $n = count($arr);

    echo '<ul>';

    for ($i = 0; $i < $n; $i++)

      echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

    echo '</ul>';

    }

     

    // needed so we can retrieve security code

    session_start();

     

    //This command imports the values from contact.php. Please do not touch.

    @import_request_variables("gpc");

     

    //The email address the message will be sent to

    $youremail = "mymail@yahoo.com";

     

    //The subject of the email you will receive;

    $subject = "Ice Rink Supply - Survey Assessment Form";

     

    //The page your visitor will be redirected to.

    $redirect = "http://www.google.com";

     

    //Time until the page redirects your visitor (seconds)

    $secs = "5";

     

    //This takes all of the information from the form and sorts it out. Please leave as is.

     

    $name= $FONT_SIZE;

     

    $FONT_SIZE=14;

    $thetext=$thetext."<html><body>\n";

    foreach ($_POST as $name => $value)

    {

    $name = str_replace('_',' ',$name);

    $thetext=$thetext."$name : <b>$value</b>\n<br/>";

    }

    $thetext=$thetext."</body></html>";

    ?>

     

     

      <?php

        infoToCheck = array("RinkName");

       

        if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

    $noEmptyFlds = count($emptyFlds) == 0;

     

    if ($noEmptyFlds && $validSecurityCode)

    {

    unset($_SESSION['key']); // prevent multiple send

    $headers .= "MIME-Version: 1.0\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

     

    $name = stripslashes($name);

      $message = stripslashes($message);

    //This is where the email is sent using your values from above.

      mail($youremail,$subject,$thetext,$headers);

    ?>

     

     

      It suppose to send a value from a text box just like an email form too.

      Basically it will not test if the textbox was fill in.

     

  4.   Once i fill up a form it not will read & test if the form was been fill in up

      suppose to be once it corrects it will send through mail php script.

      Why it does not read the name="RinkName" this

      Rink Name:  <input name="RinkName" type="text" class="form_text"> 

     

    <i> Which is my script </I>

     

     

      <?php

    function checkEmpty($names, $data) {

    $n = count($names);

    $emptys = array();

    for ($i = 0; $i < $n; $i++) {

    if (empty($data[$names[$i]])) $emptys[] = $names[$i];

    }

    return $emptys;

    }

     

    function createUList($arr) {

    $n = count($arr);

    echo '<ul>';

    for ($i = 0; $i < $n; $i++)

      echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

    echo '</ul>';

    }

     

    // needed so we can retrieve security code

    session_start();

     

    //This command imports the values from contact.php. Please do not touch.

    @import_request_variables("gpc");

     

    //The email address the message will be sent to

    $youremail = "mymail@yahoo.com";

     

    //The subject of the email you will receive;

    $subject = "Ice Rink Supply - Survey Assessment Form";

     

    //The page your visitor will be redirected to.

    $redirect = "http://www.google.com";

     

    //Time until the page redirects your visitor (seconds)

    $secs = "5";

     

    //This takes all of the information from the form and sorts it out. Please leave as is.

     

    $name= $FONT_SIZE;

     

    $FONT_SIZE=14;

    $thetext=$thetext."<html><body>\n";

    foreach ($_POST as $name => $value)

    {

    $name = str_replace('_',' ',$name);

    $thetext=$thetext."$name : <b>$value</b>\n<br/>";

    }

    $thetext=$thetext."</body></html>";

    ?>

     

     

      <?php

        infoToCheck = array("RinkName");

       

        if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

    $noEmptyFlds = count($emptyFlds) == 0;

     

    if ($noEmptyFlds && $validSecurityCode)

    {

    unset($_SESSION['key']); // prevent multiple send

    $headers .= "MIME-Version: 1.0\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

     

    $name = stripslashes($name);

      $message = stripslashes($message);

    //This is where the email is sent using your values from above.

      mail($youremail,$subject,$thetext,$headers);

    ?>

     

     

      It suppose to send a value from a text box just like an email form too.

      Basically it will not test if the textbox was fill in.

     

  5. This is my html form.

     

      <table clas="rink_form">

      <form method="post" action="form_survey.php">

        <tr>

          <td>

            Rink Name:  <input name="RinkName" type="text" class="form_text"> 

            Rink Address: <input name="RinkAdress" type="text" class="form_text">

          </td> 

        </tr>

       

        <td>Enter code below:</td>

      <td><img src="secimg.php"></td>

    </tr>

    <tr>

    <td> </td>

      <td><input type="text" name="Spam Code" size="8" /></td>

      </tr>

     

      <tr>

        <td colspan="2" align="center"><input type="submit" value="Submit Form">

          </td>

      </tr>

     

      </form>

      </table> 

     

      And heres my php script mail

     

      <?php

    function checkEmpty($names, $data) {

    $n = count($names);

    $emptys = array();

    for ($i = 0; $i < $n; $i++) {

    if (empty($data[$names[$i]])) $emptys[] = $names[$i];

    }

    return $emptys;

    }

     

    function createUList($arr) {

    $n = count($arr);

    echo '<ul>';

    for ($i = 0; $i < $n; $i++)

      echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

    echo '</ul>';

    }

     

    // needed so we can retrieve security code

    session_start();

     

    //This command imports the values from contact.php. Please do not touch.

    @import_request_variables("gpc");

     

    //The email address the message will be sent to

    $youremail = "mymail@yahoo.com";

     

    //The subject of the email you will receive;

    $subject = "Ice Rink Supply - Survey Assessment Form";

     

    //The page your visitor will be redirected to.

    $redirect = "http://www.google.com";

     

    //Time until the page redirects your visitor (seconds)

    $secs = "5";

     

    //This takes all of the information from the form and sorts it out. Please leave as is.

     

    $name= $FONT_SIZE;

     

    $FONT_SIZE=14;

    $thetext=$thetext."<html><body>\n";

    foreach ($_POST as $name => $value)

    {

    $name = str_replace('_',' ',$name);

    $thetext=$thetext."$name : <b>$value</b>\n<br/>";

    }

    $thetext=$thetext."</body></html>";

    ?>

     

    <html>

        <head> </head>

      <body>

          <?

     

    //Checks to see if the name field is empty. You can delete or add fields as needed.

     

    // fill $infoToCheck with info that NEEDS to be filled. Spam_Code is always needed here

    $infoToCheck = array("RinkAdress");

    $emptyFlds = checkEmpty($infoToCheck,$_POST);

    $validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];

    // to make displaying invalid spam code msg easier

    if (!$validSecurityCode) $emptyFlds[] = "Spam Code (invalid)";

    $noEmptyFlds = count($emptyFlds) == 0;

     

    if ($noEmptyFlds && $validSecurityCode)

    {

    unset($_SESSION['key']); // prevent multiple send

    $headers .= "MIME-Version: 1.0\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    /* <--  the ff. lines are optional

    $headers .= "From: ".$myname."

    <".$myemail.">\r\n";

    $headers .= "To:  <".$email.">\r\n";

    $headers .= "Reply-To: ".$myname."

    <$myemail>\r\n";

    $headers .= "X-Priority: 1\r\n";

    $headers .= "X-MSMail-Priority: High\r\n";

    $headers .= "X-Mailer: Just My Server";

    */ 

      $name = stripslashes($name);

      $message = stripslashes($message);

    //This is where the email is sent using your values from above.

      mail($youremail,$subject,$thetext,$headers);

    ?>

     

    <meta http-equiv="refresh" content="<?=$secs;?>;URL=<?=$redirect;?>">

    <font size="+1">

    <p align="center" class="prod_h1" style="color:#FFFFFF" >Thank you, we have recieved your Assessment Form.</p>

    <p class="rink_form" align="center" style="color:#FFFFFF">

    You are now being redirected to our <a href="<?=$redirect;?>" style="color:#00CCFF">homepage</a>.

    </font>

    <?

    }

    else

    {

    ?>

    <font size="+1">

    We require the ff. in order to reply to your message: <br/> </font>

    <?php

    if (!$noEmptyFlds) createUList($emptyFlds);

    ?>

    <center>

    <font color="#FFFFFF" size="+1">

    Please click <a href="javascript:history.back(1);" style="color:#00CCFF">here</a> or your browsers back button to try again.

    </font> <br/> <br/>

    </center>

    <?

    }

     

    ?>

     

      </body>

    </html>

     

     

      I wonder why isnt working?

    My other form that i made with a same codes, it all works.  ???

     

     

  6. if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }

          if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }

      //  if(!$subject) { $error_msg .= "<li>Subject</li>"; $error = true; }

          if(!$message) { $error_msg .= "<li>Message</li>"; $error = true; }

          if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}

          $error_msg .= "</ul>";

     

    I think i have problem in this part, i have something miss it? :( Still no solution..

  7. Now it works, it displays now an spam code but the problem now is the

    How it test if it is correct...

     

    Heres the code , In this part it wont test if the spam box was correct filling on it.

    <?php

    define("kContactEmail","name@email.com");

     

    // init variables

      $error_msg = "The following fields were left empty or contain invalid information:<ul class='error'>";

      $error = false;

     

     

      function checkEmpty($names, $data) {

      $n = count($names);

      $emptys = array();

      for ($i = 0; $i < $n; $i++) {

    if (empty($data[$names[$i]])) $emptys[] = $names[$i];

      }

      return $emptys;

    }

     

     

      function createUList($arr) {

    $n = count($arr);

    echo '<ul>';

    for ($i = 0; $i < $n; $i++)

    echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

    echo '</ul>';

    }

     

     

      // determine is the form was submitted

      $submit = $_POST['submit'];

      if (empty($submit))

    $form_submitted = false;

      else

      $form_submitted = true;

     

    if ($form_submitted) {

     

    $emptyFlds = checkEmpty($infoToCheck,$_POST);

     

    if($emptyFlds){

    }

    else{

     

      // read out data

      $name = $_POST['name'];

    $email = $_POST['email'];

      //   $subject = $_POST['subject'];

    $message = $_POST['message'];

     

     

    $validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];

     

     

    // verify required data

     

    if ($noEmptyFlds && $validSecurityCode)

    {

      unset($_SESSION['key']); // prevent multiple send

      $headers .= "MIME-Version: 1.0\r\n";

      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    }

    if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }

    if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }

      //   if(!$subject) { $error_msg .= "<li>Subject</li>"; $error = true; }

    if(!$message) { $error_msg .= "<li>Message</li>"; $error = true; }

    if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}

    $error_msg .= "</ul>";

     

    // email message if no errors occurred

    if (!$error) {

    // prepare message

      $msg = "Full Name: \t $name \n";

      $msg .= "E-mail Address: \t $email \n";

      $msg .= "Message: \n---\n $message \n---\n";

     

      // prepare message header

      $mailheaders = "MIME-Version: 1.0\r\n";

      $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";

      $mailheaders .= "From: $name <$email>\r\n";

      $mailheaders .= "Reply-To: $name <$email>\r\n";

     

    // send out email

      mail(kContactEmail, $subject ,stripslashes($msg), $mailheaders);

    }

      }

    }

    ?>

  8.  

      Hello sir,

                I tried to read it and i dont understand a little bit. What does GD do?

      And how to work out?

     

      My friend just tested this up before i have implemented on it. And it works fine and

      100% working. Now i have tried the codes but in my page doesnt work and never it

      displayed

     

      Could anyone help me that more understandable and i can easly catch up.

      Thanks..

     

  9. Hello,

    Im newbie in PHP, and till now stil learning php..

    I'm sorry but im really a pretty slow in comes of programming. :(

    But im trying my best not to discourage and keep it up till i get my goal.

    I really2x want to learn php & be part of it and starting to love on it, cause

    i know i can do it with PHP. :)

    Now im working a project a which has a spam code before it would submit and

    email it. But my problem is, It would not display the spam code or captcha..

    Heres my code.

     

    Html form

    <form action="page/contact.php" method="post" style="size:inherit" align="center">

    <p>Name: </br><input type="text" size="20" name="name" onFocus="doFocus(this,'name'); return false;"/></p>

     

    <p>Email:</br><input type="text" size="20" name="email"/></p> <p>Message </p>

    <textarea width="15" height="40" name="message" style="overflow-x:hidden;"

    rows="5" cols="20" onFocus="doFocus(this,'message'); return false;" />

    </textarea>

    <br /><br/>

    Enter code below:

    <img src="page/secimg.php"> <br/>

    <input type="text" name="Spam Code" size="7" /> <br/>

    <input type="submit" name="submit" value="SEND"size="5" name="email"/>

     

    </form>

     

    And heres my PHP script

    <?php

    session_start();

     

    $width = 120;

    $height = 40;

    $font = 'monofont.ttf';

     

    $length=5;

    $possible = '1234567890bcdfghjkmnprstvwxyzABCDEFJKMNPTUVWXY';

    $i = 0;

    while ($i < $length) {

    $string .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

    $i++;

    }

     

     

     

    //$captcha = imagecreatefrompng("./captcha.png");

    $captcha = imagecreate($width, $height);

     

     

    $back = imagecolorallocate($captcha, 0, 0, 55);

    $fore = imagecolorallocate($captcha,233,239,239);

    //$fore = imagecolorallocate($captcha,255,255,255);

     

    //imageline($captcha,40,0,64,29,$line);

    $n_lines = mt_rand(6, 8); // random number of lines

    for ($i = 0; $i < $n_lines; $i++) {

    $tm = mt_rand(1, 2); // random types of lines

    if ($tm == 1) {

    $x1 = 0;

    $y1 = mt_rand(0, $height);

    $x2 = $width;

    if ($y1 > $height / 2)

    $y2 = mt_rand(0, $height * 0.3);

    else

    $y2 = mt_rand($height * 0.5, $height);

    }

    elseif ($tm == 2) {

    $x1 = mt_rand(0,$width);

    $y1 = 0;

    if ($x1 > $width / 2)

    $x2 = mt_rand(0, $width * 0.3);

    else

    $x2 = mt_rand($width / 2,$width);

    $y2 = $height;

    }

    imageline($captcha,$x1,$y1,$x2,$y2,$fore);

    }

     

    $angle = mt_rand(-14,14); // add some angle

    $fontsize = $height * 0.70;

    $bounds = imagettfbbox($fontsize, $angle, $font, $string);

    //var_dump($bounds);

    list(,$btmleftY,,$btmrightY,$toprightX,$toprightY,,) = $bounds;

    //$x = ($width - $toprightX)/2;

    $y = ($height - $toprightY)/2;

    $x = mt_rand(5, $width - $toprightX - 5);

     

    $shootL = $height - $btmleftY;

    $shootR = $height - $btmrightY;

    if ($shootL > 0) $y - $shoot;

    else if ($shootR > 0) $y - $shoot;

     

    imagettftext($captcha, $fontsize, $angle, $x, $y, $fore, $font , $string);

     

     

    $_SESSION['key'] = md5($string);

     

    /*

    Output the image

    */

    header("Content-type: image/png");

    imagepng($captcha);

    imagedestroy($captcha);

    ?>

     

    In this part were it all checks the each textbox to verify

    <?php

    define("kContactEmail","name@email.com");

     

    // init variables

    $error_msg = "The following fields were left empty or contain invalid information:<ul class='error'>";

    $error = false;

     

     

    function checkEmpty($names, $data) {

    $n = count($names);

    $emptys = array();

    for ($i = 0; $i < $n; $i++) {

    if (empty($data[$names[$i]])) $emptys[] = $names[$i];

    }

    return $emptys;

    }

     

     

    function createUList($arr) {

    $n = count($arr);

    echo '<ul>';

    for ($i = 0; $i < $n; $i++)

    echo " <li>".str_replace('_',' ',$arr[$i])."</li>\n";

    echo '</ul>';

    }

     

     

    // determine is the form was submitted

    $submit = $_POST['submit'];

    if (empty($submit))

    $form_submitted = false;

    else

    $form_submitted = true;

     

    if ($form_submitted) {

     

    $emptyFlds = checkEmpty($infoToCheck,$_POST);

     

    if($emptyFlds){

    }

    else{

     

    // read out data

    $name = $_POST['name'];

    $email = $_POST['email'];

    // $subject = $_POST['subject'];

    $message = $_POST['message'];

     

     

    $validSecurityCode = md5($_POST['Spam_Code']) == $_SESSION['key'];

     

     

    // verify required data

     

    if ($noEmptyFlds && $validSecurityCode)

    {

    unset($_SESSION['key']); // prevent multiple send

    $headers .= "MIME-Version: 1.0\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    }

    if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }

    if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }

    // if(!$subject) { $error_msg .= "<li>Subject</li>"; $error = true; }

    if(!$message) { $error_msg .= "<li>Message</li>"; $error = true; }

    if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}

    $error_msg .= "</ul>";

     

    // email message if no errors occurred

    if (!$error) {

    // prepare message

    $msg = "Full Name: \t $name \n";

    $msg .= "E-mail Address: \t $email \n";

    $msg .= "Message: \n---\n $message \n---\n";

     

    // prepare message header

    $mailheaders = "MIME-Version: 1.0\r\n";

    $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";

    $mailheaders .= "From: $name <$email>\r\n";

    $mailheaders .= "Reply-To: $name <$email>\r\n";

     

    // send out email

    mail(kContactEmail, $subject ,stripslashes($msg), $mailheaders);

    }

    }

    }

    ?>

     

     

    It would not display the the spam code even i uploaded it at the server.

    I dont know which part should i add something in order it will display.

    Did i mess or miss something?

    Please Help me :( I just found this at the book and try to implement it

    and understand the logic code. :'(

  10.   Guys now im done in saving into the database and now my problem is, i want to display it the data

      save it from the db. Is there something missing in my code at news.php?

     

    <?php

    require_once('config.php');

     

    //The following bit of code will select the news and order the articles by their id, so if you post an article, the same article will show up at the top of the list.

    $query = mysql_query("SELECT * FROM news order by newsID desc");

     

    while($n=mysql_fetch_array($query)){

     

    $author=$n["newsAuthor"];

    $subject=$n["newsSubject"];

    $message=$n["message"];

    $date=$n["date"];

     

    echo "<b>$subject<br>$message<br>Posted by $author on $date";

     

    }

     

    ?>

     

  11.  guys i need ur help, i have jst practicing my php about w/ mySql..

     Now my codes have no errors but i dnt understand my output..

     

    config.php

    <?php

     

    //Change root to your database account's username

    $dbusername = "root";

     

    //Add your account's password in between the quotations

    $password = " ";

     

    //Add the name of the database you are using in between the quotations

    $database = " ";

     

    //This usually does not need to be changed.

    $server = "localhost";

     

    //Do not edit coding below this line.

    mysql_connect($server, $dbusername, $password) or die(mysql_error());

     

    mysql_select_db($database) or die(mysql_error());

     

    ?>

     

    add.php

    <HTML>

    <form action="<? $_SERVER['PHP_SELF']; ?>" method="POST">

    Author: <input type='text' size='30' name='author'><br><br>

    Subject: <input type='text' size='30' name='subject'><br><br>

    Message: <textarea name='message' rows='5' cols='30'></textarea><br><br>

    Date: <input type='text' size='30' name='date'><br>br>

    <input type='submit' name='submit' value='Add News'></form>

     

    <?php

    //Include the database file

    require_once('config.php');

     

    //If the submit button is pressed

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

     

     

    //Turn the inputs from the form into variables for insertion

    $author = $_POST['author'];

    $subject = $_POST['subject'];

    $message = $_POST['message'];

    $date = $_POST['date'];

     

    //Begin the database query

    $insert = mysql_query("INSERT INTO news(newsAuthor,newsSubject,newsMessage,newsDate)

    values('$author', '$subject', '$message', '$date')");

     

    //Echo a message if the news was added

    echo "The news was successfully inserted into the database.";

     

    }

     

    ?>

     

    news.php

    </php

    require_once('config.php');

     

    //The following bit of code will select the news and order the articles by their id, so if you post an article, the same article will show up at the top of the list.

    $query = mysql_query("SELECT * FROM news order by newsID desc");

     

    while($n=mysql_fetch_array($query)){

     

    $author=$n["newsAuthor"];

    $subject=$n["newsSubject"];

    $message=$n["message"];

    $date=$n["date"];

     

    echo "<b>$subject<br>$message<br>Posted by $author on $date";

     

    }

     

    ?>

     

    Now i already created my database using phpmyadmin, but whats the problem?

    it appears on this after i submit

     

    Is there anything that i mess?

    Forbidden

     

    You don't have permission to access /Practice/< on this server.

       Pls. help me i really want to know..

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