Jump to content

mcallaro88

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Posts posted by mcallaro88

  1. Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03.

    Here is the code:

    <?php
    
    $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 ";
    
    $result = mysql_query($sql);
    
    while($row = mysql_fetch_assoc($result)) {
    $id = $row['id'];
    $title = $row['title'];
    $date_posted = $row['date_posted'];
    $summary = $row['summary'];
    
    echo "<h3>$title</h3>\n";
    echo "<p>$date_posted</p>\n";
    echo "<p>$summary</p>\n";
    echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n";
    }
    
    ?>

     

    I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work.

  2. I have a php page and I'm using jQuery and some AJAX to validate my contact form (phpmailer & process.php). However, the message is never displayed in my email. The name, email, and subject get passed but the message always comes back as Message: [object HTMLTextAreaElement]. Now it comes back as undefined. I don't know whats wrong.

     

    Thanks for all who help - MIKE

     

    Here is the code

    ===============================================================

    $(function() {
      $('.error').hide();
      $('input.text-input').css({backgroundColor:"#FFFFFF"});
      $('input.text-input').focus(function(){
        $(this).css({backgroundColor:"#FFFFFF"});
      });
    
      $(".button").click(function() {
    	// validate and process form
    	// first hide any error messages
        $('.error').hide();
    
      var name = $("input#fName").val();
    	if (name == "") {
          $("label#fName_error").show();
          $("input#fName").focus();
          return false;
        }
    	var email = $("input#email").val();
    	if (email == "") {
          $("label#email_error").show();
          $("input#email").focus();
          return false;
        }
    	var subject = $("input#subj").val();
    	if (subject == "") {
          $("label#subj_error").show();
          $("input#subj").focus();
          return false;
        }
    
    var message = $("input#memo").val();
    	if (message == "") {
          $("input#memo").focus();
          return false;
        }
    
    	var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + message;
    	//alert (dataString);return false;
    
    	$.ajax({
          type: "POST",
          url: "bin/process.php",
          data: dataString,
          success: function() {
            $('.formContainer').html("<div id='message'></div>");
            $('#message').html("<h2>Contact Form Submitted!</h2>")
            .append("<p>I will be in touch soon.</p>")
            .hide()
            .fadeIn(1500, function() {
              $('#message').append("<img id='checkmark' src='images/check.png' />");
            });
          }
         });
        return false;
    });
    });
    runOnLoad(function(){
      $("input#fName").select().focus();
    });
    
    

     

  3. $(function() {
      $('.error').hide();
      $('input.text-input').css({backgroundColor:"#FFFFFF"});
      $('input.text-input').focus(function(){
        $(this).css({backgroundColor:"#FFFFFF"});
      });
    
      $(".button").click(function() {
    	// validate and process form
    	// first hide any error messages
        $('.error').hide();
    
      var name = $("input#fName").val();
    	if (name == "") {
          $("label#fName_error").show();
          $("input#fName").focus();
          return false;
        }
    	var email = $("input#email").val();
    	if (email == "") {
          $("label#email_error").show();
          $("input#email").focus();
          return false;
        }
    	var subject = $("input#subj").val();
    	if (subject == "") {
          $("label#subj_error").show();
          $("input#subj").focus();
          return false;
        }
    
    var message = $("input#memo").val();
    	if (message == "") {
          $("input#memo").focus();
          return false;
        }
    
    	var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + message;
    	//alert (dataString);return false;
    
    	$.ajax({
          type: "POST",
          url: "bin/process.php",
          data: dataString,
          success: function() {
            $('.formContainer').html("<div id='message'></div>");
            $('#message').html("<h2>Contact Form Submitted!</h2>")
            .append("<p>I will be in touch soon.</p>")
            .hide()
            .fadeIn(1500, function() {
              $('#message').append("<img id='checkmark' src='images/check.png' />");
            });
          }
         });
        return false;
    });
    });
    runOnLoad(function(){
      $("input#fName").select().focus();
    });

  4. Sorry about that I knew I forgot to put something lol here is the AJAX stuff

     

    $(function() {

      $('.error').hide();

      $('input.text-input').css({backgroundColor:"#FFFFFF"});

      $('input.text-input').focus(function(){

        $(this).css({backgroundColor:"#FFFFFF"});

      });

     

      $(".button").click(function() {

    // validate and process form

    // first hide any error messages

        $('.error').hide();

     

      var name = $("input#fName").val();

    if (name == "") {

          $("label#fName_error").show();

          $("input#fName").focus();

          return false;

        }

    var email = $("input#email").val();

    if (email == "") {

          $("label#email_error").show();

          $("input#email").focus();

          return false;

        }

    var subject = $("input#subj").val();

    if (subject == "") {

          $("label#subj_error").show();

          $("input#subj").focus();

          return false;

        }

     

    var message = $("input#memo").val();

    if (message == "") {

          $("input#memo").focus();

          return false;

        }

     

    var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + memo;

    //alert (dataString);return false;

     

    $.ajax({

          type: "POST",

          url: "bin/process.php",

          data: dataString,

          success: function() {

            $('.formContainer').html("<div id='message'></div>");

            $('#message').html("<h2>Contact Form Submitted!</h2>")

            .append("<p>I will be in touch soon.</p>")

            .hide()

            .fadeIn(1500, function() {

              $('#message').append("<img id='checkmark' src='images/check.png' />");

            });

          }

        });

        return false;

    });

    });

    runOnLoad(function(){

      $("input#fName").select().focus();

    });

  5. I have a php page and I'm using jQuery and some AJAX to validate my contact form (phpmailer & process.php). However, the message is never displayed in my email. The name, email, and subject get passed but the message always comes back as Message: [object HTMLTextAreaElement]. Could someone tell me what I'm doing wrong I've tried everything but nothing is working.

     

    Thanks for all who help - MIKE

     

    Here is the form HTML

    -------------------------------------------------------------------------------------------------------------------

     

    <div id="forminfo">

        <form name="contact" method="post" action="">

    <dl>

    <dt id="name"><label for="fName" class="">Name</label></dt>

    <dd><input type="text" class="text" name="fName" id="fName" style="width:200px; height:20px;" /></dd>

            <label class="error" for="fName" id="fName_error">This field is required.</label>

     

    <dt id="eMail"><label for="email" class="">Email</label></dt>

    <dd><input type="text" class="text" name="email" id="email" style="width:200px; height:20px;" /></dd>

            <label class="error" for="email" id="email_error">This field is required.</label>

     

    <dt id="subject"><label for="subject">Subject</label></dt>

    <dd><input type="text" size="8" maxlength="40" name="subject" id="subj" style="width:200px; height:20px;" class="text" /></dd>

            <label class="error" for="subject" id="subj_error">This field is required.</label>

     

    <dt id="comments">Message</dt>

            <dd><textarea name="memo" class="text2" id="memo"></textarea></dd>

     

    <dd><input type="submit" class="button" id="submit" name="submit" value="" /></dd>

    </dl>

    </form>

    </div><!--forminfo-->

     

     

    Here is the php

    -------------------------------------------------------------------------------------------------------------------

     

    <?php

    if ((isset($_POST['fName'])) && (strlen(trim($_POST['fName'])) > 0)) {

    $name = stripslashes(strip_tags($_POST['fName']));

    } else {$name = 'No name entered';}

    if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) {

    $email = stripslashes(strip_tags($_POST['email']));

    } else {$email = 'No email entered';}

    if ((isset($_POST['subj'])) && (strlen(trim($_POST['subj'])) > 0)) {

    $subject = stripslashes(strip_tags($_POST['subj']));

    } else {$subject = 'No subject entered';}

    if ((isset($_POST['memo'])) && (strlen(trim($_POST['memo'])) > 0)) {

    $comments = stripslashes(strip_tags($_POST['memo']));

    } else {$comments = 'No message entered';}

    ob_start();

    ?>

    <html>

    <head>

    <style type="text/css">

    </style>

    </head>

    <body>

    <table width="550" border="1" cellspacing="2" cellpadding="2">

      <tr bgcolor="#eeffee">

        <td>Name</td>

        <td><?=$name;?></td>

      </tr>

      <tr bgcolor="#eeeeff">

        <td>Email</td>

        <td><?=$email;?></td>

      </tr>

      <tr bgcolor="#eeffee">

        <td>Subject</td>

        <td><?=$subject;?></td>

      </tr>

      <tr bgcolor="#eeffee">

        <td>Message</td>

        <td><?=$comments;?></td>

      </tr>

    </table>

    </body>

    </html>

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