The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - Just a Simple PHP form Processing Freelance
Discuss Just a Simple PHP form Processing Freelance in the PHP Development forum on Dev Shed. Just a Simple PHP form Processing Freelance PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 12th, 2013, 12:39 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation Power: 0
|
|
|
PHP-General - 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.
|

February 12th, 2013, 12:51 PM
|
|
|
|
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.
|

February 12th, 2013, 01:01 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
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.
__________________
"WERE NOT WORTHY!"
"WERE NOT WORTHY!"
Last edited by Nanomech : February 12th, 2013 at 01:05 PM.
|

February 12th, 2013, 01:31 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation 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> </p>
<p> </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 © 2013 | <a href="http://dianamagers.com">Diana Magers</a> | Spring Semester 2013 </p>
<p> </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>
|

February 12th, 2013, 01:42 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
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 01:45 PM.
|

February 12th, 2013, 03:01 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation 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 © 2013 | <a href="http://dianamagers.com">Diana Magers</a> | Spring Semester 2013 </p>
<p> </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>
|

February 12th, 2013, 03:03 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation 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
|

February 12th, 2013, 03:53 PM
|
|
|
php Code:
Original
- 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:
Original
- php Code |
|
|
|
if (condition) { } else (condition) { }
construct in PHP. There's
php Code:
Original
- php Code |
|
|
|
if (condition) { } else if (condition) { }
.
But, unless you're providing more that one gender, a simple if/else
php Code:
Original
- php Code |
|
|
|
if (condition) { } else { }
should suffice.
__________________
I ♥ ManiacDan & requinix
This is a sig, and not necessarily a comment on the OP:
Please don't be a help vampire!
Last edited by ptr2void : February 12th, 2013 at 03:58 PM.
|

February 12th, 2013, 04:07 PM
|
|
Contributing User
|
|
Join Date: Jun 2009
Posts: 294
  
Time spent in forums: 3 Days 8 h 5 m 6 sec
Reputation Power: 5
|
|
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 04:12 PM.
|

February 12th, 2013, 04:13 PM
|
|
|
|

February 12th, 2013, 04:14 PM
|
|
Contributing User
|
|
Join Date: Jun 2009
Posts: 294
  
Time spent in forums: 3 Days 8 h 5 m 6 sec
Reputation Power: 5
|
|
|
Removed...
Last edited by Triple_Nothing : February 12th, 2013 at 07:10 PM.
|

February 12th, 2013, 04:24 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation Power: 0
|
|
|
I agree totally
Quote: | 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.
|

February 12th, 2013, 04:41 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Location: Rocky Mount, NC
Posts: 16
Time spent in forums: 2 h 38 m 11 sec
Reputation 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 © 2013 | <a href="http://dianamagers.com">Diana Magers</a></p>
<p> </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 04:43 PM.
Reason: forgot to show my url
|

February 12th, 2013, 06:47 PM
|
|
Contributing User
|
|
Join Date: Jun 2009
Posts: 294
  
Time spent in forums: 3 Days 8 h 5 m 6 sec
Reputation Power: 5
|
|
|
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.
|

February 12th, 2013, 06:54 PM
|
 |
Lost in code
|
|
|
|
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($first, ENT_QUOTES, 'UTF-8'); ?>"><br />
<label for="last">Last Name:</label>
<input type="text" name="last" id="last" value="<?php echo htmlentities($last, ENT_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'])){
Quote: | 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($first, ENT_QUOTES, 'UTF-8') , htmlentities($last, ENT_QUOTES, 'UTF-8') , "Welcome to my Portfolio! I will be getting back with you as soon as possible";
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|