Jump to content

Changing a buttons text

- - - - -

  • Please log in to reply
6 replies to this topic

#1
hoku_2000 _99

hoku_2000 _99

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
Right now, I have a button that says 'Submit Query' when I would like it to read just 'Submit', I've tried putting a label, but when I do so, the email doesnt send. Then when I add value="Submit" to my input, the email doesnt send either.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<!-- 
Author: Reality Software 
Website: http://www.realitysoftware.ca 
Note: This is a free template released under the Creative Commons Attribution 3.0 license,  
which means you can use it in any way you want provided you keep the link to the author  

intact. 
--> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Contact</title> 
<link href="style.css" rel="stylesheet" type="text/css" /></head> 
<body> 
    <!-- header --> 
    <div id="header"> 
        <div id="logo"><a href="#">Header</a></div> 
        <div id="menu"> 
            <ul> 
            <li><a href="#">Home</a></li> 
            <li><a href="#">Link 1</a></li> 
            <li><a href="#">Link 2</a></li> 
            <li><a href="#">Link 3</a></li> 
            <li><a href="#">Contact</a></li> 
        <li><a href="#">Guestbook</a></li> 
            </ul> 
      </div> 
  </div> 
    <!--end header --> 
    <!-- main --> 
    <div id="main"> 
    <div id="content"> 

    
 <div id="text"> 
                <h1><strong>Contact</strong></h1> 
</div> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/> 

<?php   
       
        if (isset($_POST['Submit'])) {   
       
            if ($_POST['name'] != "") {   
                $_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);   
                if ($_POST['name'] == "") {   
                    $errors .= 'Please enter a valid name.<br/><br/>';   
                }   
            } else {   
                $errors .= 'Please enter your name.<br/>';   
            }   
       
            if ($_POST['email'] != "") {   
                $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);   
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {   
                    $errors .= "$email is <strong>NOT</strong> a valid email  

address.<br/><br/>";   
                }   
            } else {   
                $errors .= 'Please enter your email address.<br/>';   
            }   
       
            if ($_POST['message'] != "") {   
                $_POST['message'] = filter_var($_POST['message'], FILTER_SANITIZE_STRING);   
                if ($_POST['message'] == "") {   
                    $errors .= 'Please enter a message to send.<br/>';   
                }   
            } else {   
                $errors .= 'Please enter a message to send.<br/>';   
            }   
       
            if (!$errors) {   
                $first_name=$_POST['name']; 
        $email_address=$_POST['email']; 
        $subject = 'Test';  
        $message=$_POST['message']; 

        mail("myemailaddress@gmail.com","$subject", 
        $message,"From: $first_name <$email_address>");  
       
                echo "Thank you for your email!<br/><br/>";   
            } else {   
                echo '<div style="color: red">' . $errors . '<br/></div>';   
            }   
        }   
    ?>   
       
    <form method="post" action="test.php">   
    Name: <br/>   
    <input type="text" name="name" value="<?php echo $_POST['name']; ?>" size="50"  

/><br/><br/>   
    Email Address: <br/>   
    <input type="text" name="email" value="<?php echo $_POST['email']; ?>" size="50"/>  

<br/><br/>   
    Message: <br/>   
    <textarea name="message" rows="5" cols="50"><?php echo $_POST['message']; ?></textarea>   
    <br/>   
         
    
    <input type="submit" name="Submit"/>   
     
                            
    </form> 
          
     
     <!-- footer --> 
<br/> 
<br/> 
<br/> 


    <div id="footer"> 
    <div id="left_footer">© Copyright 2011<strong> Author </strong></div> 
    <div id="right_footer"> 

<!-- Please do not change or delete this link. Read the license! Thanks. :-) --> 
Design by <a href="http://www.realitysoftware.ca" title="Website Design">Reality  

Software</a> 

<!-- end footer --></div> 
<!-- end main --></div> 
</body> 
</html>



#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Hello, there are often quirks in how HTML elements get their names from. In this case, <button>s or <input type="submit">s get their display name modified with value=""

<input type="submit" name="Submit" value="Click Me!"/>

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
hoku_2000 _99

hoku_2000 _99

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
I just tried adding value="submit", my email sends, but when I check to see if I got an email, nothing in my inbox or spam.

---------- Post added at 04:37 PM ---------- Previous post was at 04:24 PM ----------

Also my error messages dont show up.

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
This is a little vague, does mail() return false? are you on a shared host, or local host with a proper mail transport agent set up (i.e. sendmail?)

How do you know the email has sent?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
hoku_2000 _99

hoku_2000 _99

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
I figured it out, in my
if (isset($_POST['Submit'])) { 
I have 'Submit' and in my <input> markup . I have capital 's' and a lower case 's', I had to have either lower case or upper case, not both.

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Glad it was as simple as that, some mail diagnostics/setup can get long.

Alexander.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
hoku_2000 _99

hoku_2000 _99

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
Thanks for the help! :) I too am glad it was something simple.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users