# Login question



## GSquadron (May 25, 2011)

Hi guys!
I am a bit new to php, but i want to learn a lot!
This time i have an homework making a login.
I do the login with forms, buttons and the action, but all i get is this:

Mirsevini Z/Znj 
*Notice: Undefined index: emri in C:\Program Files\EasyPHP-5.3.6.0\www\login.php on line 3
!*
Ju jeni perdoruesit e ketij e-maili: 
*Notice: Undefined index: e-mail in C:\Program Files\EasyPHP-5.3.6.0\www\login.php on line 4
!*

I saw in google that they added smth like this:

/ / Before you use $ _POST [ 'trick'] 
if (isset ($ _POST [ 'trick'])) 
( 
 / / Instructions if $ _POST [ 'trick'] exists 
) 

I edit the writting to name them to my form, but i get a *parse* error
This is weird :S


----------



## Deleted member 3 (May 25, 2011)

Post your code. Also, code in English.


----------



## GSquadron (May 25, 2011)

This is the show.html file:

<html>
<head>
<title>Acid Network</title>
<link rel="stylesheet" type="text/css" href="styles/styles.css" />
</head>
<body>
<div id="Page into pieces" style="width:1272px">


<div id="title" style="background-color:#008000;">
<h1 style="margin-bottom:0;">Acid Network</h1></div>
<script src="http://h2.flashvortex.com/display.php?id=2_1306330558_25_347_0_468_60_9_2_98" type="text/javascript" style="align: center"></script>

<div id="menu" style="background-color:#FFD700;height:778px;width:128px;float:left;"><br>
	<img src="images/gradient_menu.jpg" />
	<a href="index.html">Home</a><br>
	<a href="register.html">register</a><br>
	<a href="show.html">show</a><br>
	<a href="search engine.html">search engine</a><br>
	<a href="about us.html">about us</a><br>
	<a href="contact.html">contact</a><br>
</div>


<div id="other menu">
<img src="images/regjistrohuni.jpg" width="800" height="90" alt="<h10>Regjistrohuni!</h10>" /><br></br>
<img src="images/gradient.jpg" style: z-index:-5; /><br></br>
Ketu do te shfaqen manifestimet e ndryshme si dhe cmimet qe faqja jone ka fituar neper organizata te ndryshme<br><br>
<i>Here we will show our achievements and our trophies we have won in world wide organizations</i><br><br><br><br>
<form name="login" action="login.php" method="post" enctype="multipart/form-data">
name:<input type="text" value="" /><br><br>
e-mail:<input type="text" value="" /><br><br>
<input type="submit" value="login"/><br><br>
</div>


<div id="footer" style="background-color:#32CD32;clear:both;text-align:center;">
Powered by AleX©</div>

</div>

</body>
</html>

And this here is the login.php:

<html>
<body>
Welcome Mr/Ms <?php echo $_POST["name"]; ?>!<br />
You use this e-mail: <?php echo $_POST["e-mail"]; ?>!<br />
</body>
</html>

The error code this time in english would be:

Welcome Mr/Ms
*Notice: Undefined index: emri in C:\Program Files\EasyPHP-5.3.6.0\www\login.php on line 3
!*
You are using this e-mail:
*Notice: Undefined index: e-mail in C:\Program Files\EasyPHP-5.3.6.0\www\login.php on line 4
!*


----------



## Disparia (May 25, 2011)

The inputs need names:


```
name:<input type="text" name="name" /><br><br>
e-mail:<input type="text" name="e-mail" /><br><br>
```

isset() is a way to tell if a variable is set, but that doesn't mean it isn't empty.


```
Welcome Mr/Ms 
<?php
if ( isset($_POST['name']) && strlen($_POST['name']) )
	echo $_POST['name'];
} else {
	echo 'Anonymous';
?>!
```

Using !empty() would also work.


----------



## GSquadron (May 25, 2011)

Still it says:
*Parse error*: syntax error, unexpected '}' in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\login.php on line 7

line 7 is: } else {
I dont get it why is an error here?


----------



## Disparia (May 25, 2011)

Whoops. I forget a curly.

if ( isset($_POST['name']) && strlen($_POST['name']) ) *{*


----------



## GSquadron (May 25, 2011)

Still it says:
*Parse error*: syntax error, unexpected $end in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\login.php on line 11
I dunno what the problem is with </html>???? That is on line 11


----------



## temp02 (May 25, 2011)

*Jizzler*s code is good, he just forgot two curlys, to fix it, just remove both curlys around the "else" on the welcome thingy, and it _should_ work


----------



## GSquadron (May 25, 2011)

you are wrong temp, it says error on line 7 were is the *else*


----------



## temp02 (May 25, 2011)

Aleksander Dishnica said:


> you are wrong temp, it says error on line 7 were is the *else*



For it to compile either you have curlys around the if code and the else code or you have no curlys and a single statement on both the if and the else parts, my guess is that you still have a curly after the if.


----------



## Disparia (May 25, 2011)

Yup, I'm a cut-n-paste fail today 


```
if ( isset($_POST['name']) && strlen($_POST['name']) ) {
    echo $_POST['name']; 
} else { 
    echo 'Anonymous';
}
```

The parser stops at line 7 because it's the first place that is in error. Having no curly braces is valid, which is why you don't get an error two lines up. It's only when the parser finds an unexpected } that it throws an error.


----------



## GSquadron (May 25, 2011)

Problem solved


----------

