Page 1 of 1

facebook with php

Posted: Fri Jul 30, 2010 12:02 am
by rini06
hello..
I am newbie to php as well as to your forum also.I am making facebook like website as a project.
i am getting some problems:
1) I do not how to make the border cover whole screen like in login page of facebook. i am getting like your where your heading is there means i want no margins.
2)I want to make a text box which will be displayed only when user has entered something wrong else it will be hidden.
3)I want to pass the variable to third page from first page so that i can display username. for which i have used session but session doesn't save in insert.
4)i want to sh0w updates from friends also..i am working on it but please some main points for it..

here is my code:as extension php is not allowed to attach so pasting the code

login

Code: Select all

<?php
session_start();
?><html>
<head>
<title>
Login
</title>
<style type="text/css">
<!--

#header
{
	background-color:#036;
	padding:10px 0 10px 850px;
	margin:0 0 60px 0;
	color:#FFF;
	}	
#signup
{
	color:#036;
	margin:4px 2px 40px 850px;
	}	
	
#form
{
	color:#036;
	margin:0 2px 40px 870px;}
body {
	font-family: Times New Roman, Times, serif;
}
 -->
 </style>
</head>
<body>
<div id="header">
<form method="post" action="db_finsert.php">
<small>Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Password
</small><br/>
<input type="text" name="id"/>&nbsp;&nbsp;&nbsp;<input type="password" name="pwd"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="searchbutton" type="submit"name="submit" value="Login"/><br/>
<input type="checkbox" name="log"><small><em>keep me logged in &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forgot your password?</em></small>
</div>
<div>
<h2>
Sign Up
</h2>
</div>
<div id="form">
<small>First Name:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="fname" style="width:15em;"> <br/></small>
<small>Last Name :&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="lname" style="width:15em;"> <br/></small>
<small>Your Email:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="email" style="width:15em;"> <br/></small>
<small>I am:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="sex">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Select Sex" selected="Selected Sex">Select Sex</option>
</select>
</small>
<br/>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="s"type="submit" value="sign up" name="sign up" style="width:5em;"></p>
<br/>
</div>
<div id="warning">
<p><input type="hidden" name="warning" value="You must fill in all the data." >
</p>
</div>
</form>
</body>
</html>
for insering new user data and checking for valid user

Code: Select all

<?php
session_start();
$con=mysql_connect("localhost","root","") or die (mysql_error($con));
mysql_select_db('facebook',$con);
$_SESSION['user']=$_POST['id'];
$user=$_SESSION['user'];

$_SESSION['pass']=$_POST['pwd'];
$pass=$_SESSION['pass'];

if($_POST['submit']=='Login')
{
 $query="select username from user where username='$user' and password='$pass'";
 $result=mysql_query($query);
 if(!$result) {
   $err=mysql_error();
   print $err;
   exit();
}
else if(mysql_num_rows($result)==0){
   print "Username or password is not correct";
   exit();
}
else{
   header("Location: profile.php?user=$user" );
}
}

?>
and my profile page:

Code: Select all

<?php
session_start();
?>
<html>
<head>
<title>Profile page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
<!--
body,td,th {
	font-family:Georgia, "Times New Roman", Times, serif;
	color: #000;
}
body {
	background-color: #FCF;
}
a:link {
	color: #FFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #300;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
	color: #090;
}
ul  
{
	margin:0.5em;
	padding:0;	
	list-style-type:none;
	overflow:hidden;
	}
	li
	{
		display:inline;
		}
-->
</style>

<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css">
</head>
<body >

<table  cellpadding="0"  cellspacing="10" frame="box"/ >
<tr bgcolor="#FFFFFF"/>
<td colspan="2">
<ul>
<li>MYsite&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li> home  &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</li>
<li> profile&nbsp;&nbsp;|</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;<input align="right" type="text" name="searchbox"/></li>
<li><input align="right" type="submit" name="search" value="Search"/> </li>
</ul>
</tr>
<tr>
<td>
<tr >
<td>
<img align="left" src="taylor-swift1.jpg" border="2" width="140px" height="150px"/>
<h2>Welcome, <?php echo $_SESSION["user"]; ?></h2>
</td>
<td rowspan="2" width="1000px"> 
friends
</td>
</tr>
<tr>
<td height="10" ><ul id="MenuBar1" class="MenuBarHorizontal">
  <li><a href="login.php" target="display">Profile</a>
  </li>
  <li><a href="">Photos</a></li>
  <li><a href="">Videos</a></li>
  <li><a href="">Messages</a></li>
</ul>
</tr>
</td>
<tr>
<td width="1000px">
<iframe name="display" height="1000px" width="1000px" frameborder="0" scrolling="auto">
</iframe>
</td>
</tr>
</tr>
</table>
<script type="text/javascript">
<!--

var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>

please reply as soon as possible

Re: facebook with php

Posted: Fri Jul 30, 2010 1:50 pm
by Baseball435
Well for 2 (make something hidden then come back) I'm pretty sure you would have to use Ajax or JavaScript. Ajax is probably the way to go with this and kind of has a flash feel to it, so it would slide down or fade in if you made it that way. But it wouldn't be too complicated. If you have never used Ajax before (which I don't think you have) use w3schools as they have a great tutorial learning section on Ajax