when click on submit button it return number

Asked by:
HubFans / n/a Points
Time:
2014-04-27 2:35 pm EST
Category:
Billing
Hits:
122
hi sir

im new in php

i have a simple code contain a register.php as above:

<html>
<body>
<form action="login.php" method="POST">
<table>
<tr><td>firstname</td>
<td><input type="text" name= "fname" /></td>

<tr><td>lastname</td>
<td><input type="text" name= "lname" /></td>
</tr>
</table>
<input type="submit" name="submit" value="register"/></form>
</body>
</html>

second page is login.php and code is:

<?php


$fentry =isset($_POST['fname']);
$lentry =isset($_POST['lname']);

if(isset($_POST['submit']))
{
echo 'welcome' . "$fentry" . "$lentry";


}


?>


question is : when click on submit button it return ((welcome 1.1)) and not the value which i post>>>which is mean when enter for example abc on first name text field it will echo 1 and not abc which i enterd >>>>thank you for you Patience

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

ScottM
Staff
16,266 Points
2014-04-28 8:27 am EST
Hello,

You are receiving a 1 for each name in the echo because the variable is not set to what is passed. It is currently being set to the return code of the isset() function. These are returning 1 as they are true.

If you change the code:
$fentry =isset($_POST['fname']);
$lentry =isset($_POST['lname']);

to the following:
$fentry =$_POST['fname'];
$lentry =$_POST['lname'];

they will echo the first and last names as you desire.

Kindest Regards,
Scott M

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}