Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    Just a Simple PHP form Processing Freelance


    Hello, I am trying to teach myself how to process a simple form in php. Here is what I want to do. I have a simple form.html document and I want to have input fields for First Name and Last Name and Gender.

    The Gender field I want to be able to send them the right message if they enter 'M' for Male or 'F' for Female I want to be able to say something like 'Welcome 'Mr or Mrs' First Name and Last Name' in an echo statement.

    Here is the code I have thus far.
    I have this in the body of my welcome.php page

    Code:
     <?php
    
    //import form information 
    $first = $_POST['first'];
    $last = $_POST['last'];
    $gender = $_POST['gender'];
    
    
     
     if($gender=="M"){
    	 echo Thank you for your submission;
    	 echo 'Hello, Mr. <?php echo $first $last ?>, Welcome to my Portfolio!  I will be getting back with you as soon as possible';
     }elseif($gender == 'F'){
     	 echo 'Thank you for your submission';
    	 echo 'Hello, Mrs. <?php echo $first $last ?> Welcome to my Portfolio!  I will be getting back with you as soon as possible'; 
     }
     ?>
    And here is my form on my html page

    Code:
    <form method="post" action="welcome.php">
                    
                    <p>
                      <label for="first">First Name:</label> 
                      <input type="text" name="$first" id="first"><br />
                      <label for="last">Last Name:</label> 
                      <input type="text" name="$last" id="last"><br />
                      <label for="gender">Type 'M' for Male or 'F' for Female:</label>
                      <input type="text" name="$gender" id="gender" /><br />
                        
                      <br>
                    </p>
                    
                    <input id="subbut" type="submit" value="Send Comment">
    </form>
    I am not sure what is going on. From all the books I have read and tutorials on the internet I still get a error message through Dreamweaver.

    Would someone be so kindto point me in the right direction. I would greatly appreciate it.

    Thank you in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,616
    Rep Power
    595
    1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum.
    2) What error are you getting? Dreamweaver only does a fair job of warning you about HTML errors but it does nothing about PHP errors. It just helps to a limited extent by formatting your PHP for you.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    300
    Rep Power
    9
    You do know that 'm' is not the same as 'M' and 'f' is not the same as 'F'. Don't allow your program too much room for mistakes.

    Give them 2 radio buttons.
    Code:
    Male<input type="radio" name="gender" value="Male" /><br />
    Female:<input type="radio" name="gender" value="Female" />
    Then change your welcome.php to this:
    PHP Code:
    //import form information 
    $first $_POST['first'];
    $last $_POST['last'];
    $gender $_POST['gender'];


     if(
    $gender=="Male"){
         echo 
    "Thank you for your submission";
         echo 
    "Hello, Mr. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible";
     }else(
    $gender == "Female"){
          echo 
    "Thank you for your submission";
         echo 
    "Hello, Mrs. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible"
     } 
    You had a few errors; no quotations around your first string, use of open and closing <php?> tags while already in 'PHP mode' and an unnecessary 'elseif' statement because there is only 2 possible answers, so it's either one or the other so you only need an if else, not an if elseif else. Be aware if you use an if elseif, then you MUST have an 'else' statement ending the elseif. You can do an 'if' on it's own though without an else. Still use a textbox to get their names but in cases when you know there is a limited amount of possible values and only certain ones, you should display a drop down list, or checkboxes/radio buttons IMO.

    Hope this helps.

    Regards,

    NM.
    Last edited by Nanomech; February 12th, 2013 at 02:05 PM.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    Still something not right


    I tried the code

    Code:
    <form method="post" action="welcome.php">
                    
                    <p>
                      <label for="first">First Name:</label> 
                      <input type="text" name="$first" id="first"><br />
                      <label for="last">Last Name:</label> 
                      <input type="text" name="$last" id="last"><br />
                      Male<input type="radio" name="gender" value="Male" /><br />
    				  Female:<input type="radio" name="gender" value="Female" />
                        
                      <br>
                    </p>
                    
                    <input id="subbut" type="submit" value="Send Comment">
    </form>
    for my html document and for that welcome.php file I changed the code to the following:

    Code:
     <?php
    //import form information  
    $first = $_POST['first']; 
    $last = $_POST['last']; 
    $gender = $_POST['gender']; 
    
    
     if($gender=="Male"){ 
         echo "Thank you for your submission"; 
         echo "Hello, Mr. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible";
      }else($gender == "Female"){ 
          echo "Thank you for your submission"; 
         echo "Hello, Mrs. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible"; 
      }
      ?>
    The response that I first got wanted to see the entire code which is:

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    
            <meta charset="utf-8">
            <title>Diana Magers | Contact Page</title>
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta name="description" content="#">
            <meta name="author" content="Diana Magers">
            
            <link rel="stylesheet" media="screen,projection" href="css/ui.totop.css" />
            
            <link href="./css/style.css" rel="stylesheet">
            <link rel="stylesheet" href="css/easy.css" media="screen" />
    		<link rel="stylesheet" href="css/easyprint.css" media="print" />
    
         
    
    <style type="text/css">
    		@import url("css/Prociono_Regular/stylesheet.css");
    		@import url("css/Vollkorn/stylessheet.css");
    
    		
    		 h4 {
    			font-size: 24px;
    			color: #F3C;
    			font-family:Vollkorn;
    		}
    		
    	
    		 h2 {
    			font-family: 'VollkornRegular';
    		}
    		
    		 p {
    	font-family: Vollkorn;
    	font-size: x-large;
    	color: #003;
    	padding-left: 50px;
    		}
    		
    .background-illusion .container div p {
    	font-size: 16px;
    }
    </style>
    
    
    
            <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]--> 
            
            <script src="jquery.min.js" type="text/javascript"></script> 
           	<script type="text/javascript" src="js/easy.js"></script>
    		<script type="text/javascript" src="js/main.js"></script>
            <script src="./js/less.js"type="text/javascript"></script>
            <script src="./js/cufon.js"type="text/javascript"></script>
            <script src="jquery.min.js" type="text/javascript"></script> 
            
            
    
    
    
    
    
    
    
    </head> 
    <body>
            <header class="background-illusion">
            <img src="./img/logo1.png" class="logo" alt="" /></header>
            
    <div class="container">
            <h1><span class="left">Contact</span><span class="right">Me</span></h1>
     <p>&nbsp;</p>
                  <p>&nbsp;</p>
      <?php
    //import form information  
    $first = $_POST['first']; 
    $last = $_POST['last']; 
    $gender = $_POST['gender']; 
    
    
     if($gender=="Male"){ 
         echo "Thank you for your submission"; 
         echo "Hello, Mr. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible";
      }else($gender == "Female"){ 
          echo "Thank you for your submission"; 
         echo "Hello, Mrs. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible"; 
      }
      ?>
    </div>
            <div id="toTop"></div>        
            
    <footer class="background-illusion">
                <div class="container">
                   
    
    
                  </div>
      </div>
    </footer>
            
            	<!-- jquery -->	
    <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    	<!-- easing plugin ( optional ) -->
    <script src="js/easing.js" type="text/javascript"></script>
    	<!-- UItoTop plugin -->
    <script src="js/jquery.ui.totop.js" type="text/javascript"></script>
    	<!-- Starting the plugin -->
    <script type="text/javascript">
    		$(document).ready(function() {
    			
    			var defaults = {
    	  			containerID: 'toTop', // fading element id
    				containerHoverID: 'toTopHover', // fading element hover id
    				scrollSpeed: 1200,
    				easingType: 'linear' 
    	 		};
    			
    			
    			$().UItoTop({ easingType: 'easeOutQuart' });
    			
    		});
    	</script>
        
    	
    </body>
    </html>
    And here is my index.html file

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Diana Magers | Contact Me</title>
            
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta name="description" content="#">
            <meta name="author" content="Diana Magers">
            
            <link rel="stylesheet" media="screen,projection" href="css/ui.totop.css" />
            
            <link href="./css/style.css" rel="stylesheet">
            <link rel="stylesheet" href="css/easy.css" media="screen" />
    		<link rel="stylesheet" href="css/easyprint.css" media="print" />
    
         
    
    <style type="text/css">
    		@import url("css/Prociono_Regular/stylesheet.css");
    		@import url("css/Vollkorn/stylessheet.css");
    
    		
    		 h4 {
    			font-size: 24px;
    			color: #F3C;
    			font-family:Vollkorn;
    		}
    		
    	
    		 h2 {
    			font-family: 'VollkornRegular';
    		}
    		
    		 p {
    	font-family: Vollkorn;
    	font-size: x-large;
    	color: #003;
    	margin-top: 25px;
    	margin-right: auto;
    	margin-bottom: 25px;
    	margin-left: auto;
    		}
    		
    .background-illusion .container div p {
    	font-size: 16px;
    }
    </style>
    
    
            <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]--> 
            
            <script src="jquery.min.js" type="text/javascript"></script> 
           	<script type="text/javascript" src="js/easy.js"></script>
    		<script type="text/javascript" src="js/main.js"></script>
            <script src="./js/less.js"type="text/javascript"></script>
            <script src="./js/cufon.js"type="text/javascript"></script>
            <script src="jquery.min.js" type="text/javascript"></script> 
            
           
    
    </head> 
    <body>
            <header class="background-illusion">
            <img src="./img/logo1.png" class="logo" alt="" /></header>
            
            <div class="container">
            <h1><span class="left">Contact</span><span class="right">Me</span></h1>
           
           
            <form method="post" action="welcome.php">
                    
                    <p>
                      <label for="first">First Name:</label> 
                      <input type="text" name="$first" id="first"><br />
                      <label for="last">Last Name:</label> 
                      <input type="text" name="$last" id="last"><br />
                      Male<input type="radio" name="gender" value="Male" /><br />
    				  Female:<input type="radio" name="gender" value="Female" />
                        
                      <br>
                    </p>
                    
                    <input id="subbut" type="submit" value="Send Comment">
    </form>
    
    </div>
            <div id="toTop"></div>        
            
    <footer class="background-illusion">
                <div class="container">
                    <div align="center">
                      <p>Copyright &copy; 2013 | <a href="http://dianamagers.com">Diana Magers</a> | Spring Semester 2013 </p>
                      <p>&nbsp;</p>
                      <script language="javascript">
    <!--
    document.write("<i>Last updated "+document.lastModified+"<I>");
    //--></script>
    
    
                    </div>
                </div>
            </footer>
            
            	<!-- jquery -->	
    	<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    	<!-- easing plugin ( optional ) -->
    	<script src="js/easing.js" type="text/javascript"></script>
    	<!-- UItoTop plugin -->
    	<script src="js/jquery.ui.totop.js" type="text/javascript"></script>
    	<!-- Starting the plugin -->
    	<script type="text/javascript">
    		$(document).ready(function() {
    			
    			var defaults = {
    	  			containerID: 'toTop', // fading element id
    				containerHoverID: 'toTopHover', // fading element hover id
    				scrollSpeed: 1200,
    				easingType: 'linear' 
    	 		};
    			
    			
    			$().UItoTop({ easingType: 'easeOutQuart' });
    			
    		});
    	</script>
        
    	
    </body>
    </html>
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    300
    Rep Power
    9
    Make index.html into index.php . You can't run PHP in a .html file unless you change a specific value in a PHP's .htaccess file.

    I still don't understand where welcome.php comes into it. The first code block's <title> is 'Contact Us' and the second is your index.html.

    Try what I said and I think it should work. Try changing the 'action' attribute of your form to 'index.php'. Then change index.html to index.php and put your form processing code at the VERY TOP of yourdocument, even before your HTML doctype.

    Regards,

    NM.
    Last edited by Nanomech; February 12th, 2013 at 02:45 PM.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    Ok check this out


    http://dianamagers.com/Contact/index.php


    This is the source code

    Code:
     <?php
    //import form information  
    $first = $_POST['first']; 
    $last = $_POST['last']; 
    $gender = $_POST['gender']; 
    
    
     if($gender=="Male"){ 
         echo "Thank you for your submission"; 
         echo "Hello, Mr. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible";
      }else($gender == "Female"){ 
          echo "Thank you for your submission"; 
         echo "Hello, Mrs. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible"; 
      }
      ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Contact Me</title>
            
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta name="description" content="#">
            <meta name="author" content="Diana Magers">
            
            <link rel="stylesheet" media="screen,projection" href="css/ui.totop.css" />
            
            <link href="./css/style.css" rel="stylesheet">
            <link rel="stylesheet" href="css/easy.css" media="screen" />
    		<link rel="stylesheet" href="css/easyprint.css" media="print" />
    
         
    
    <style type="text/css">
    		@import url("css/Prociono_Regular/stylesheet.css");
    		@import url("css/Vollkorn/stylessheet.css");
    
    		
    		 h4 {
    			font-size: 24px;
    			color: #F3C;
    			font-family:Vollkorn;
    		}
    		
    	
    		 h2 {
    			font-family: 'VollkornRegular';
    		}
    		
    		 p {
    	font-family: Vollkorn;
    	font-size: x-large;
    	color: #003;
    	margin-top: 25px;
    	margin-right: auto;
    	margin-bottom: 25px;
    	margin-left: auto;
    		}
    		
    .background-illusion .container div p {
    	font-size: 16px;
    }
    </style>
    
    
            <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]--> 
            
            <script src="jquery.min.js" type="text/javascript"></script> 
           	<script type="text/javascript" src="js/easy.js"></script>
    		<script type="text/javascript" src="js/main.js"></script>
            <script src="./js/less.js"type="text/javascript"></script>
            <script src="./js/cufon.js"type="text/javascript"></script>
            <script src="jquery.min.js" type="text/javascript"></script> 
            
           
    
    </head> 
    <body>
            <header class="background-illusion">
            <img src="./img/logo1.png" class="logo" alt="" /></header>
            
            <div class="container">
            <h1><span class="left">Contact</span><span class="right">Me</span></h1>
          
           
            <form method="post" action="index.php">
                    
                    <p>
                      <label for="first">First Name:</label> 
                      <input type="text" name="$first" id="first"><br />
                      <label for="last">Last Name:</label> 
                      <input type="text" name="$last" id="last"><br />
                      Male<input type="radio" name="gender" value="Male" /><br />
    				  Female:<input type="radio" name="gender" value="Female" />
                        
                      <br>
                    </p>
                    
                    <input id="subbut" type="submit" value="Send Comment">
    </form>
    
    </div>
            <div id="toTop"></div>        
            
    <footer class="background-illusion">
                <div class="container">
                    <div align="center">
                      <p>Copyright &copy; 2013 | <a href="http://dianamagers.com">Diana Magers</a> | Spring Semester 2013 </p>
                      <p>&nbsp;</p>
                      <script language="javascript">
    <!--
    document.write("<i>Last updated "+document.lastModified+"<I>");
    //--></script>
    
    
                    </div>
                </div>
            </footer>
            
            	<!-- jquery -->	
    	<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    	<!-- easing plugin ( optional ) -->
    	<script src="js/easing.js" type="text/javascript"></script>
    	<!-- UItoTop plugin -->
    	<script src="js/jquery.ui.totop.js" type="text/javascript"></script>
    	<!-- Starting the plugin -->
    	<script type="text/javascript">
    		$(document).ready(function() {
    			
    			var defaults = {
    	  			containerID: 'toTop', // fading element id
    				containerHoverID: 'toTopHover', // fading element hover id
    				scrollSpeed: 1200,
    				easingType: 'linear' 
    	 		};
    			
    			
    			$().UItoTop({ easingType: 'easeOutQuart' });
    			
    		});
    	</script>
        
    	
    </body>
    </html>
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    Logic


    This logic appears correct but it keeps giving me an error is on line 10.

    Code:
    Parse error: syntax error, unexpected T_VARIABLE, expecting '}' in /hermes/bosoraweb013/b122/ipg.dianamagerscom/Contact/index.php on line 10
  14. #8
  15. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,556
    Rep Power
    2338
    php Code:
     if($gender=="Male"){ 
         echo "Thank you for your submission"; 
         echo "Hello, Mr. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible";
      }else($gender == "Female"){ 
          echo "Thank you for your submission"; 
         echo "Hello, Mrs. {$first $last}, Welcome to my Portfolio! I will be getting back with you as soon as possible"; 
      }


    There is no

    php Code:
    if (condition) {
    } else (condition) {
     
    }


    construct in PHP. There's

    php Code:
    if (condition) {
     
    } else if (condition) {
     
    }
    .

    But, unless you're providing more that one gender, a simple if/else

    php Code:
    if (condition) {
     
    } else {
     
    }
    should suffice.
    Last edited by ptr2void; February 12th, 2013 at 04:58 PM.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7
    Please correct me if I'm wrong, but I believe ptr2void is correct for the most part, cept I don't believe there's exactly a

    PHP Code:
    if (condition) {
     
    } else if (
    condition) {
     

    but more a

    PHP Code:
    if (condition) {
     
    } elseif (
    condition) {
     
    } else {


    Nanomech did a fair job trying to point this out. This is why your script feels such is missing.

    EDIT: And a note... Since you're echo-ing in double quotes, it may also help to remove your curly brackets around the user's name. Or are these to be printed on the visible content page in the end?

    EDIT2: And just a thing to throw out there... As far as the female member, perhaps something to decide between Mrs and Ms? Not sure best way to decide this other than directly querying whether married or not. Or perhaps a different manner of referencing male/female? Sir/Madam or such?
    Last edited by Triple_Nothing; February 12th, 2013 at 05:12 PM.
  18. #10
  19. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,556
    Rep Power
    2338
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7
    Removed...
    Last edited by Triple_Nothing; February 12th, 2013 at 08:10 PM.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    I agree totally


    Originally Posted by Triple_Nothing
    Please correct me if I'm wrong, but I believe ptr2void is correct for the most part, cept I don't believe there's exactly a

    PHP Code:
    if (condition) {
     
    } else if (
    condition) {
     

    but more a

    PHP Code:
    if (condition) {
     
    } elseif (
    condition) {
     
    } else {


    Nanomech did a fair job trying to point this out. This is why your script feels such is missing.

    EDIT: And a note... Since you're echo-ing in double quotes, it may also help to remove your curly brackets around the user's name. Or are these to be printed on the visible content page in the end?

    EDIT2: And just a thing to throw out there... As far as the female member, perhaps something to decide between Mrs and Ms? Not sure best way to decide this other than directly querying whether married or not. Or perhaps a different manner of referencing male/female? Sir/Madam or such?
    I agree totally. I fixed it to Ms. instead of Mrs. Because you are right in my case I wouldn't want to be called 'Mrs.' since I am not married. Good point.
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Location
    Rocky Mount, NC
    Posts
    16
    Rep Power
    0

    Made a few changes else if \\ else and Mrs. to Ms.


    Made a few changes and after completing the form all it does is clears my selection. In my browser, it says that Gender was not selected before I even start to fill out the form. After filling out the form it comes up what I want but it doesn't display the $first and $last name <variable>. I know I am close to this but I am trying to be patient. I appreciate everyone's help in this matter.

    http://dianamagers.com/Contact/index.php

    Code:
     <?php
    //import form information  
    $first = $_POST['first']; 
    $last = $_POST['last']; 
    $gender = $_POST['gender']; 
    
    
     if($gender=="Male"){ 
         echo "Thank you for your submission"; 
         echo "Hello, Mr. $first $last, Welcome to my Portfolio! I will be getting back with you as soon as possible";
      }else if($gender == "Female"){ 
          echo "Thank you for your submission"; 
          echo "Hello, Ms. $first $last, Welcome to my Portfolio! I will be getting back with you as soon as possible"; 
      }else {
    		echo "A Gender was not selected";  
      }
     
      ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Contact Me</title>
            
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta name="description" content="#">
            <meta name="author" content="Diana Magers">
            
            <link rel="stylesheet" media="screen,projection" href="css/ui.totop.css" />
            
            <link href="./css/style.css" rel="stylesheet">
            <link rel="stylesheet" href="css/easy.css" media="screen" />
    		<link rel="stylesheet" href="css/easyprint.css" media="print" />
    
         
    
    <style type="text/css">
    		@import url("css/Prociono_Regular/stylesheet.css");
    		@import url("css/Vollkorn/stylessheet.css");
    
    		
    		 h4 {
    			font-size: 24px;
    			color: #F3C;
    			font-family:Vollkorn;
    		}
    		
    	
    		 h2 {
    			font-family: 'VollkornRegular';
    		}
    		
    		 p {
    	font-family: Vollkorn;
    	font-size: x-large;
    	color: #003;
    	margin-top: 25px;
    	margin-right: auto;
    	margin-bottom: 25px;
    	margin-left: auto;
    		}
    		
    .background-illusion .container div p {
    	font-size: 16px;
    }
    </style>
    
    
            <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]--> 
            
            <script src="jquery.min.js" type="text/javascript"></script> 
           	<script type="text/javascript" src="js/easy.js"></script>
    		<script type="text/javascript" src="js/main.js"></script>
            <script src="./js/less.js"type="text/javascript"></script>
            <script src="./js/cufon.js"type="text/javascript"></script>
            <script src="jquery.min.js" type="text/javascript"></script> 
            
           
    
    </head> 
    <body>
            <header class="background-illusion">
            <img src="./img/logo1.png" class="logo" alt="" /></header>
            
            <div class="container">
            <h1><span class="left">Contact</span><span class="right">Me</span></h1>
          
           
            <form method="post" action="index.php">
                    
                    <p>
                      <label for="first">First Name:</label> 
                      <input type="text" name="$first" id="first"><br />
                      <label for="last">Last Name:</label> 
                      <input type="text" name="$last" id="last"><br />
                      Male<input type="radio" name="gender" value="Male" /><br />
    				  Female:<input type="radio" name="gender" value="Female" />
                        
                      <br>
                    </p>
                    
                    <input id="subbut" type="submit" value="Send Comment">
    </form>
    
    </div>
            <div id="toTop"></div>        
            
    <footer class="background-illusion">
                <div class="container">
                    <div align="center">
                      <p>Copyright &copy; 2013 | <a href="http://dianamagers.com">Diana Magers</a></p>
                      <p>&nbsp;</p>
                      <script language="javascript">
    <!--
    document.write("<i>Last updated "+document.lastModified+"<I>");
    //--></script>
    
    
                    </div>
                </div>
            </footer>
            
            	<!-- jquery -->	
    	<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    	<!-- easing plugin ( optional ) -->
    	<script src="js/easing.js" type="text/javascript"></script>
    	<!-- UItoTop plugin -->
    	<script src="js/jquery.ui.totop.js" type="text/javascript"></script>
    	<!-- Starting the plugin -->
    	<script type="text/javascript">
    		$(document).ready(function() {
    			
    			var defaults = {
    	  			containerID: 'toTop', // fading element id
    				containerHoverID: 'toTopHover', // fading element hover id
    				scrollSpeed: 1200,
    				easingType: 'linear' 
    	 		};
    			
    			
    			$().UItoTop({ easingType: 'easeOutQuart' });
    			
    		});
    	</script>
        
    	
    </body>
    </html>
    Last edited by dlmagers; February 12th, 2013 at 05:43 PM. Reason: forgot to show my url
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7
    A gender was not selected wil display simply because your if/then is running at the loading of the page, even if no submission was made. You are also getting more errors, which I assume your server is not passing on. When arriving at the page initially, you are trying to set some variables from a $_POST[] that was never made.

    Just to keep these seperate, I usually write all this upper scripting in a simple if/then inquiring which stage of login we are. The action attribute in your form tag may benifit if changed to something like "index.php?stage=2". Then, wrapping around your top processing, would be an if() statement asking if(isset($_GET['stage']) && $_GET['stage'] == 2) then run those items.

    The way you defined your names in the textbox name field is incorrect. Remove the $ from those.
  28. #15
  29. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    Code:
    <label for="first">First Name:</label> 
    <input type="text" name="$first" id="first"><br />
    <label for="last">Last Name:</label> 
    <input type="text" name="$last" id="last"><br />
    Your name attributes should not have a $ in front of them.

    ----

    To preserve the submitted values, you must output them back out to the HTML in the value attribute:
    PHP Code:
    <label for="first">First Name:</label> 
    <input type="text" name="first" id="first" value="<?php echo htmlentities($firstENT_QUOTES'UTF-8'); ?>"><br />
    <label for="last">Last Name:</label> 
    <input type="text" name="last" id="last" value="<?php echo htmlentities($lastENT_QUOTES'UTF-8'); ?>"><br />
    ----

    To check a radio button by default, you must use the checked attribute:
    PHP Code:
    <input type="radio" name="gender" value="Male" <?php if($gender == "Male") echo "checked"?> />
    ----

    This block will throw errors if your form is on the same page as your processing code:
    PHP Code:
    $first $_POST['first']; 
    $last $_POST['last']; 
    $gender $_POST['gender']; 
    Use isset instead:
    PHP Code:
    $first = isset($_POST['first']) ? $_POST['first'] : ''
    $last = isset($_POST['last']) ? $_POST['last'] : ''
    $gender = isset($_POST['gender']) ? $_POST['gender'] : ''
    ----

    If you don't want to display an error message on the initial load, change your }else{ block in the gender check to }elseif(!empty($_POST['gender'])){

    An if() can run on its own w/o an else, but on a multi-stage, there must be an else at the end.
    There is no situation in PHP in which an else block is required.

    ----

    PHP Code:
    echo "Hello, Mr. $first $last, Welcome to my Portfolio! I will be getting back with you as soon as possible"
    To prevent XSS attacks, you must use htmlentities.

    PHP Code:
    echo "Hello, Mr. " htmlentities($firstENT_QUOTES'UTF-8') , htmlentities($lastENT_QUOTES'UTF-8') , "Welcome to my Portfolio! I will be getting back with you as soon as possible"
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo