php


Why isn't this simple sign up page working?


I'm not sure why this isn't working, It is giving me no errors, but it won't display the results. I just want to display the results of the 3 text fields. The next step I want to go about doing is entering the data into a database, then displaying it, but I guess that will come next. Thank you.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$Pword = $_POST["Pword"];
if (!isset($_POST['submit'])) { // if page is not
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<form method = "post" action = "<?php echo $PHP_SELF;?>">
First name<input name="Fname" type="text" maxlength="12"
/>
<br />
<br />
Last name<input name="Lname" type="text" maxlength="12"
/>
<br />
<br />
<!--Address <input name="register_address" type="text" maxlength="12"
/>
<br />
<br />-->
<!--<select name="state" value="State"></select>-->
Password<input name="Pword" type="text" maxlength="12"
/>
<br />
<br />
<!--Re-type Password<input name="register_password_confirm" type="text" maxlength="12"
/>
<br />
<br />-->
<input name="submit" type="button" value="Submit" />
</form>
<?
} else {
echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "Your Password is, " .$Pword.".<br />";
}
?>
</body>
</html>
Three issues I see
1 - Your button is not a submit button
Change:
<input name="submit" type="button" value="Submit" />
to
<input name="submit" type="submit" value="Submit" />
2 - Register globals may be turned off
Change:
<?php echo $PHP_SELF;?>
to
<?php echo $_SERVER['PHP_SELF'];?>
3 - Short open tags may be turned off
Change:
<?
} else {
echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "Your Password is, " .$Pword.".<br />";
}
?>
to
<?php
} else {
echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "Your Password is, " .$Pword.".<br />";
}
?>
Your submit button needs to be changed to type="submit", also you might want to move your variable declarations within the else statement to avoid PHP warnings:
<input name="submit" type="submit" value="Submit" />
and:
<?php
} else {
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$Pword = $_POST["Pword"];
echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "Your Password is, " .$Pword.".<br />";
}
?>
Lastly, I would reduce the amount of html you put it the if statement to the bare minimum, this could cause conflicts if you change how the condition is handled in the future:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) { // if page is not
?>
<form method = "post" action = "<?php echo $_SERVER['PHP_SELF'];?>">
First name<input name="Fname" type="text" maxlength="12" /><br /><br />
Last name<input name="Lname" type="text" maxlength="12" /><br /><br />
<!--Address <input name="register_address" type="text" maxlength="12" /> <br /> <br />-->
<!--<select name="state" value="State"></select>-->
Password<input name="Pword" type="text" maxlength="12" /><br /><br />
<!--Re-type Password<input name="register_password_confirm" type="text" maxlength="12" /><br /><br />-->
<input name="submit" type="submit" value="Submit" />
</form>
<?php
} else {
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$Pword = $_POST["Pword"];
echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "Your Password is, " .$Pword.".<br />";
}
?>
</body>
</html>
Try adding a
<input type="hidden" name="submitted" value="1" />
and checking for
$_POST['submitted'] == 1
try echoing the result like this:
echo "Hello, $Fname $Lname.<br />
Your Password is, $Pword.<br />";
I forgot to add that you don't need the dots after variables when echoing using double quotations.

Related Links

How to configure Doctrine for MongoDB master/slave replica to automatically failover
How to compare Iphone system Device Date with PersianDate?
Get data from database with MySQL in forloop
Automated API scraping + data cleaning?
Create a function to output a category hierarchy into a select drop down form input by passing the $categories array to the function
How to validate mandatory associated model in cakephp 3
Manage permissions in a Symfony application
Codeigniter & jquery Ajax
Ninja Forms hooks
Laravel 5 Controller using variable arguments
BindingResolutionException on redirect in Laravel 5.2
How to get a sub-string between to characters?
how to print a json property value in my html codes?
Opencart 2.2-2.3 auto update products list from ERP
Redirection from Bootstrap modal with PHP data capture
PHP Set Variable On MYSQL Data

Categories

HOME
hpoo
opengl
xpath
ionic2
entity-framework
firebase
protocol-buffers
mod-rewrite
verification
xcode8.1
jms
long-integer
workflow
foaf
hdfs
initialization
semantic-web
biztalk-2010
tibco
visualforce
firebase-database
onvif
tweepy
timber
gtk
heuristics
clish
pm2
smartgwt
bundler
trace32
dma
twisted
nest-api
android-5.1.1-lollipop
vertica
google-sites
office-ui-fabric
significance
scheduled-tasks
android-custom-view
bluemix-mobile-services
angular2-highcharts
node-webkit
candlestick-chart
eclipse-emf
pyopencl
beego
acrobat
sendmessage
sfml
mdns
envoy
caesar-cipher
xmlunit
dreamfactory
xerces-c
numerics
jade4j
cargo
ms-dos
cloudera-quickstart-vm
mars-simulator
selenide
right-click
game-center
cloudera-sentry
julius-speech
liteide
intellij-lombok-plugin
sony-future-lab-n
ilrepack
hibernate-ogm
cordova-ios
line-intersection
gtk#
deedle
lvalue
oid
gapi
scheduledexecutorservice
bigdecimal
tablespace
data-management
nsrunloop
livecycle
wolfram-language
unsigned
apache-pig-grunt
simian
accessibilityservice
pack
chicagoboss
netdatacontractserializer
uitest
physicsjs
camus
symja
zend-mail
inputbox
xcode6.3.1
iosched
vlab
colon
ggts
frontbase
insertonsubmit
notifyjs
days
contextswitchdeadlock
cyrillic
jsplitpane
semantic-merge
towers-of-hanoi
telerik-ajax
uitextfielddelegate
trialware
algol68
type-safety
qtextbrowser
datacontracts
botnet
startupscript
principles
raw-data
subtext
tacit-programming
twitter-feed

Resources

Encrypt Message