Image Submit Button ( PHP File )

Discussion in 'PHP' started by newzone, Nov 4, 2008.

  1. #1
    I have a submit form and i want to use an image button but i can't , in a html file is working fine but in a php file nothing happens.

    How to create an image submit button in a php file ? thank you
     
    newzone, Nov 4, 2008 IP
  2. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #2
    <input type="image" src="image/url.gif" />
     
    crazyryan, Nov 4, 2008 IP
  3. newzone

    newzone Well-Known Member

    Messages:
    2,865
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #3
    is not working in a file with a .php extension , only html
     
    newzone, Nov 4, 2008 IP
  4. softnmore

    softnmore Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    can you pls show your php file code ? may be you are missing something... such as use of <form> tag...
     
    softnmore, Nov 4, 2008 IP
  5. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #5
    just use input type="submit" and customise it using CSS

    they will look the same
     
    ads2help, Nov 4, 2008 IP
  6. Sir P

    Sir P Peon

    Messages:
    76
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6

    are you seeing an error of some kind?

    can you show us the source...

    maybe you need to echo it ..

    echo("<input type='image' src='image/url.gif' />");
    PHP:
     
    Sir P, Nov 4, 2008 IP
  7. newzone

    newzone Well-Known Member

    Messages:
    2,865
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #7
    here is the code :

     
    newzone, Nov 4, 2008 IP
  8. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #8
    
    <?php
    if(isset($_POST["send"]))
    {
    $name = $_POST["name"];
    $url = $_POST["url"];
    $email = $_POST["email"];
    $subject = $_POST["subject"];
    $msg = $_POST["msg"];
    $ip = $_SERVER['REMOTE_ADDR'];
    $receiver = "email@domain.com";
    
    if(empty($name))
    {
    echo(" - There was no name!<br />");
    }
    // CHECK IF EMAIL IS VALID ////////////////////////////////////////////////////////////////////
    function CheckMail($email) {
    if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email)) { return true; }
    else { return false; }
    }
    if ((empty($email)) || (!CheckMail($email)))
    {
    Die(" - Please go back and fill in a valid e-mail adress!");
    }
    // CHECK IF EMAIL IS VALID ////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////
    // CHECK IF THE FORM HAS BEEN FILLED
    if(empty($subject)){
    echo(" - There was no subject!<br />");
    }
    if(empty($msg)){
    echo(" - There was no message!<br />");
    }
    ////////////////////////////////////////////////////////////////////
    // IF THEIR ARE NOT EMPTY
    if(!empty($name) && !empty($email) && !empty($subject) && !empty($msg))
    {
    $headers .= "From: ".$email."";
    // WE STORE THE MESSAGE IN A VARIABLE
    $messageproper =
    
    "This message was sent from: $name - $email \n" .
    "URL\n" .
    "------------------------- Form Mail-------------------------\n\n" .
    "Name: $name\n" .
    "Site Url: $url\n" .
    "Email: $email\n" .
    "Message: $msg\n" .
    "Sender Ip: $ip\n" .
    
    "\n------------------------------------------------------------\n";
    
    mail("$receiver", $subject, $messageproper, "From: Mail Form < $email>");
    echo( '<br />
    ---------------------------------------------------------------------------------------------------------------<br />
    Thank you <strong>' . $name . '</strong>, your email was sent! And your IP has been logged <strong> IP: ' .$ip .'</strong><br />
    ---------------------------------------------------------------------------------------------------------------<br />' );
    } } ?>
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
    <strong>Name:</strong><br />
    <input type="text" name="name" size="35" /><br />
    <strong>Site Url:</strong>*<br />
    <input type="text" name="url" size="35" /><br />
    <strong>E-mail:</strong><br />
    <input type="text" name="email" size="35" /><br />
    <strong>Subject:</strong><br />
    <input type="text" name="subject" size="35" /><br />
    <strong>Message:</strong><br />
    <textarea name="msg" rows="8" cols="42"></textarea><br />
    <input name="send" type="image" src="images/button.png" value="Send Email"/>
    </form> 
    
    PHP:
    Your name of the image input was "Send", and your php code checked with if(isset($_POST["send"]))
    Since that's a case-sensitive string, "Send" == "send" will return false :)
     
    elias_sorensen, Nov 4, 2008 IP
    jacobbannier likes this.
  9. newzone

    newzone Well-Known Member

    Messages:
    2,865
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #9
    I'm happy now, is working , thank you :)
     
    newzone, Nov 4, 2008 IP
  10. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #10
    You're welcome.
     
    elias_sorensen, Nov 4, 2008 IP