<?php session_start(); ?>

<html>

<head>

</head>

<body>
<script type="text/javascript">

function validateForm()

{
var z=document.forms["login"]["email"].value;
var atpos=z.indexOf("@");
var dotpos=z.lastIndexOf(".");

	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=z.length)

	  {

	  alert("Invalid E-mail address");

	  return false;

	  }
	document.login.submit();
}

//function submitform(){


	//document.login.action='homepage.php' ;
	 
//}

</script>

<style type="text/css"> 

h1 {

	font-family: calibri;

	color: black;

	font-size: 24;

}

 

p {

	font-family: calibri;

	color: black;

	font-size: 20;

}
a
{
	font-family: calibri;

	color: black;

	font-size: 14;
}
td
{
	
	font-family: calibri;

	color: black;

	font-size: 14;
}


</style>

<table width="100%" height="100%" border="0">

<tr>

<td colspan="2" style="background-color:#F6F6F6;text-align:center;">

<h1>Welcome to Trade Fun !</h1>

</td>

</tr>



<tr valign="top" height="85%">

<td style="background-image:url('bull.gif');background-size:100% 100%;
background-repeat:no-repeat;background-color:#A7D1A7;width:200px;text-align:top;">


<marquee direction="up" scrollamount="3" height="100%" width="100%"><b><i style="color:white;font-size:16"> Whether you are a seasoned investor or a newbie, come join our online simulated trading floor to learn what investing is all about !</br></br>- Buy and sell stocks while staying in the financial loop with our Newsfeed</br></br>- Talk to people like you using our interactive forum </br></br>Do all this and more while you play the game !</i></b></marquee>

</td>



<td style="background-image:url('gray.jpg');background-size:100% 100%;
background-repeat:no-repeat;height:330px;width:955px;text-align:top;">



<p>LOGIN</p>



<br>&nbsp<br/>

<p>

<form name="login" action="login.php" method="post">

Email: <input type="text" name="email" /><br /><br />

Password: <input type="password" name="passwrd" /><br /><br />

<input type="submit" name="submit" value="Login" onclick="validateForm()"></input>

 </form>
 
 
</p>

<br />

<table width="100%" height="150" border="0">

<tr>

<td>

<img border="0" src="newuser.gif" alt="New User?" width="75" />

<a href="registration.php">New User?</a> 

</td>

<td>

<img border="0" src="forgotpassword.jpg" alt="Forgot Password?" width="75" />

<a href="C:\wamp\www\stocks\forgotpassword.php">Forgot Password?</a> 

</td>

</tr>

</table>

</td>

</tr>
<tr height="10">

<td colspan="2" style="background-color:#F6F6F6;text-align:center;">

Copyright © 2011 Tradefun.com</td>

</tr>

</table>

<?php 
error_reporting(E_ALL ^ E_NOTICE);

$con= mysql_connect("localhost:3306","","");
if (!$con)
{
	die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$email= $_POST["email"];
$password= $_POST["passwrd"];
$check = mysql_query("SELECT * FROM userdata WHERE Email = '$email' and Password = '$password'");
$check2 = mysql_num_rows($check);
$submit=$_POST["submit"];

if (isset($_POST["submit"]))
{	 

 if($check2>0)
 {	
  //session_start();
$_SESSION['login'] = "1";
$_SESSION['email'] = $email;
header ("Location: homepage.php");
 }
else
{
echo "<script language=javascript>alert('No registered user. Please register to play.')</script>";
//session_start();
$_SESSION['login'] = '';
$_SESSION['email'] = '';

}
 
 
}
 mysql_close($con);
?>


</body>

</html> 