Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. try run this so you can see the timezone that's throwing the error and post back

    require_once("dbconnection.php");
    
    function coun_list()
    {
    $rs=mysql_query("select name from timezones") or die(mysql_error());
    while($row=mysql_fetch_row($rs))
      {
       $tzone=$row[0];
       if($tzone=='Asia/Calcutta') $tzone='Asia/Kolkata';
       try {
           $tz = new DateTimeZone("$tzone");
           $lt=$tz->getLocation();
           $lat=$lt['latitude'];
           $lon=$lt['longitude'];
           echo "$tzone";		
           }
          catch (Exception $e) {
            echo 'Caught exception on timezone ['.$tzone.']: ',  $e->getMessage(), "\n";
           }
      }
    }
    
    coun_list();
    

  2. from php.net

    $to = 'email@domain.com, email2@domain.com';
    
    // 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 .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    

  3. you could have three select elements with year, month, day and then check is_numeric() on each of the fields to ensure validity

    <select name='year'>
    <?php for ($i=1990;$i<2020;$i++) {
    echo "<option value='$i'>$i</option>";
    } ?>
    </select>
    
    //do again for month, day... though month you would have the value as the numeric month and the displayed value as the month name
    

  4. you need to use the concatenate operator to combine the BCC addresses, or put them into an array and implode like so

    $query  = "SELECT email FROM zipdatabase WHERE zip = '$ZIP'";
    $result = mysql_query($query);
    $bccs = array();
    while($row = mysql_fetch_array($result))
    {
       $bccs[] = $r['email'];
    }
    $bccs = implode(",",$bccs);
    #should echo email1@rara.com, email2@rara.com etc
    echo $bccs;
    

  5. is something like this what you're after?

     

    you need to enclose the select name in quotes;

    echo "<select multiple name='vaccination[]' value=''><option>de hond is behandeld tegen:</option>";
    

     

    and then when you process the form (this assumes the dog's id is stored in the session under the session variable dog_id

    if (is_array($_POST['vaccination'])) {
    foreach ($_POST['vaccination'] AS $vaccination) {
    $dog = $_SESSION['dog_id'];
    @mysql_query("INSERT INTO vaccination SET
    vaccination_id='$vaccination',
    dog_id='$dog'");
    }
    

  6. how are you choosing which form to display?

    and you're posting it with ajax...?

    add "document.formName.reset();" to your validateHeader function to reset the form - where formName is the name of your form

    and to have form B display after your submit form B, how are you choosing which form to display? is it posting the form and then reloading the page from scratch? if so use an $_GET variable in the URL to indicate which form it is... i.e. post formB to annual_report_main.php?form=b and then when you load that page, use

    if (isset($_GET['form'])) {
    switch ($_GET['form']) {
    case "b":
    echo "formB";
    break;
    
    case "c":
    echo "formC";
    break;
    
    default:
    echo "default Form A";
    break;
    }
    }
    

  7. you should separate the functions from the code, and it's the die(); function being called in your 'died()' function which is stopping the rest of the page from showing... try somethign like this

    <?php
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        }
    
         
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        }
    
    if(isset($_POST['email'])) {
         
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "luka@fer-projekt.com";
        $email_subject = "Your email subject line";
         
    
         
    $error = false;
    
        // validation expected data exists
        if(!isset($_POST['first_name']) ||
            !isset($_POST['last_name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['telephone']) ||
            !isset($_POST['comments'])) {
            $error_message = 'We are sorry, but there appears to be a problem with the form you submitted.';  
    $error=true;
        } 
    
        $first_name = $_POST['first_name']; // required
        $last_name = $_POST['last_name']; // required
        $email_from = $_POST['email']; // required
        $telephone = $_POST['telephone']; // not required
        $comments = $_POST['comments']; // required
         
        $error_message = (isset($error_message))?$error_message:'';
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
    $error=true;
      }
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$first_name)) {
        $error_message .= 'The First Name you entered does not appear to be valid.<br />';
    $error=true;
      }
      if(!preg_match($string_exp,$last_name)) {
        $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
    $error=true;
      }
      if(strlen($comments) < 2) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br />';
    $error=true;
      }
    
    #check that errors weren't set
      if($error) {
    
        $email_message = "Form details below.\n\n";
         
        $email_message .= "First Name: ".clean_string($first_name)."\n";
        $email_message .= "Last Name: ".clean_string($last_name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Telephone: ".clean_string($telephone)."\n";
        $email_message .= "Comments: ".clean_string($comments)."\n";
         
         
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers); 
    
    echo 'Thank you for contacting us. We will be in touch with you very soon.';
    
    }
    
    
      }
    

  8. this will add the class to the <div class='homebox'> div...

     

      <?php query_posts('showposts=3&cat=20&orderby=rand'); 
    $i = 0;
    while (have_posts()) : the_post(); 
    $i++;
    $class = ($i%3==0 && $i<>0)? "last" : ""; ?>
    <div class="homeBox <?php echo $class; ?>">
    <div class="boxgrid caption">
    <a href="<?php the_permalink();?>"><?php the_post_thumbnail(); ?>
    <div class="cover boxcaption">
    <h2><?php the_title();?></h2>
    </div> </a>
    </div>
    </div>
    
    <?php endwhile;?>
    

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