Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. have an IF ISSET declaration to check whether any forms are posted, if not just echo the normal page.

    i.e.

    if (isset($_POST['submitButton'])) {
    //do whatever with the form
    } else {
    //form not sent, so echo form to be filled out
    echo "<form method='POST'>
    <input name='input1' type='text' />
    <input type='submit' name='submitButton' value='Submit Form'/>
    </form>";
    }
    

  2. Use the get_browser() function. There is a nice user contributed function in the notes (2nd one, by 'ruudrp at live dot nl')

    To ensure it worked, I would set the IF to show the flash slideshow only in tested browsers which work.

    i.e.

    $browser = get_browser(null, true);
    if ($browser['browser']=='Firefox' || $browser['browser']=='Other working browser') {
    //echo the flash
    } else {
    //echo the simple slideshow
    }
    

  3. try this

     

    //mail code
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $address = $_REQUEST['address'] ;
    $pname = $_REQUEST['pname'] ;
    $pdescription = $_REQUEST['pdescription'];
    $plow = $_REQUEST['plow'] ;
    $phigh = $_REQUEST['phigh'] ;
    $purl = $_REQUEST['purl'] ;
    $ponline = $_REQUEST['ponline'] ;
    //default to none uploaded, then overwrite if image uploaded
    $emailImage = "None Uploaded";
    
    //get picture
    if($_FILES)
    { 
    $img = $_FILES['filename']['img'];
    
    switch($_FILES['filename']['type'])
    {
    case 'image/jpeg' : 
    $ext = 'jpg'; 
    break;
    
    case 'image/png' : 
    $ext = 'png'; 
    break;
    
    default: $ext = ''; 
    break;
    }
    if ($ext)
    {
    $n = "image.$ext";
    move_uploaded_file($_FILES['filename']['tmp_name'], $n);
    echo "<span class='uploaded-photo'>uploaded image '$img'  as '$n':</span> <br />";
    echo "<img src='$n' />";
    $emailImage = "<img src='http://{$_SERVER["SERVER_NAME"]}$n' />";
    }
    else echo "'$img' is not a supported image file";
    $emailImage = 'Image not of supported types';
    }
    
    if (!isset($_REQUEST['email'])) {
        echo "we need your name and email address please" ;
      }
    
    elseif (empty($name)){
    echo "please enter your name";
    }
    elseif (empty($email)){
    echo "please enter your email address";
    }
    elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})", "$email")) {
    echo"please check your email address - it doesn't appear to be a valid format";
    }
    else {
        mail( "admin@website.com.au", "subject",
         "$name\n $email\n $phone\n $address\n $pname\n $pdescription\n $plow\n $phigh\n $purl\n $ponline\n $emailImage\n ", "$email");
       
        header( "Location: ../index.php" );
      }
    
    
    

  4. just realised I forgot to close the while loop

    $values=array();
    while ($row=mysql_fetch_array($sql)) 
    { $values[]= "<tr>
    <td>column1: {$row['column1']}</td>
    <td>value: {$row['value1']}</td></tr>";
    }
    $values=array_reverse($values);
    foreach ($values AS $row) {
    echo $row;
    }
    

  5. Yes that is whats happening in the code so far, it is working from a page on the server because you're pointing to the image relative to the page, though once you're trying to view it from outside your server you need to add http://www.yourdomain.com/whateverFolders/image.jpg

    You also need to include the <img> HTML tag

    //i don't know your domain, so i'm using $_SERVER['server_name'] which returns www.phpfreaks.com if it were run on the php freaks server
    $image = "<img src='http://{$_SERVER["SERVER_NAME"]}$n' />";
        mail( "eamail@address.com", "Subject",
         "$name\n $email\n $phone\n $address\n $pname\n $pdescription\n $plow\n $phigh\n $purl\n $ponline\n $image\n $img", "$email");
    

     

    You don't want to overwrite the image, set the image name to have time() at the end of it which is the amount of seconds passed since jan 1 1970... in other words as long as 2 images aren't uploaded in the same second then you won't have any problems.

     

    if ($ext)
    {
    $n = "image".time().".$ext";
    move_uploaded_file($_FILES['filename']['tmp_name'], $n);
    echo "<span class='uploaded-photo'>uploaded image '$img'  as '$n':</span> <br />";
    echo "<img src='$n' />";
    }
    else echo "'$img' is not a supported image file";
    }
    

  6. you can't just send an image in an email like that, you must add it as an attachment... or link to a url.

    In that email you're linking to an image via URL, though the URL is relative to the server upload, not the email...

    you need the email's image tag to include the full path

    <img src='http://www.domain.com/images/upload/image.jpg' />

     

    If you want to attach the image, you'll have to read up on some tutorials or use something like php mailer()

  7. oh!

    totally misunderstood what you were after

     

    I dare say you'll have to pull those most recent 5 and then use some PHP trickery to order them unless someone more learned in MySQL can help?

     

    If you're just echoing a simple table from it, add each row value to an array like

    $values=array();
    while ($row=mysql_fetch_array($sql)) 
    { $values[]= "<tr>
    <td>column1: {$row['column1']}</td>
    <td>value: {$row['value1']}</td></tr>";
    
    $values=array_reverse($values);
    foreach ($values AS $row) {
    echo $row;
    }
    

     

    ... though looking at that situation and how convoluted it has become, I dare say someone else could suggest a much simpler way

     

  8. have a look at this form tutorial to learn about forms

    Then you'll have to (as Bradley99 said) set the form's action="search-term.php" and method="POST"

     

    Then on search-term.php you can have code such as

    //assuming the search text input is named 'searchTerm'
    //check if searchTerm is being posted
    if (isset($_POST['searchTerm'])) {
    echo $_POST['searchTerm'];
    //do whatever else you want if a search term is 
    }
    

     

    You can change the method to GET instead of POST, and the form input will be sent across in the URL such as

    www.domain.com/search-term.php?searchTerm=bunny rabbit

  9. I would use the .htaccess (URL rewriting) to pull all search terms from the URL (if you're running an apache server), i.e. www.yourdomain.com/search/searchTermHere Here is a tutorial on .htaccess URL rewriting

    Then use php to generate the page on demand and echo the search term...

     

    What are you searching through? Pages in your site, or pages on external sites?

    Without using a database I think you will be putting a lot of strain on your server unnecessarily...

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