
Luis Martin
1
Lambda
Verificado
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
Suscripción a IA
Hola amigos estoy intentando hacer una pequeña red social con mis pocos conocimientos, he creado hasta el momento lo siguiente:
index.php
base.php
registrar.php
style.css
ingreso.php
registro.php
home.php
logout.php
Lo que quiero hacer:
-Que cada usuario que se registre, automaticamente se le cree una pagina de su perfil, en donde pueda elegir una foto o cambiar los datos de su cuenta, y luego que en cada pagina que ande por la web lo reconozca por su usuario.
como lo podria hacer? gracias 😀
index.php
Insertar CODE, HTML o PHP:
<?php
session_start();
include("base.php");
if ( isLogged() ) {
header('Location: home.php');
}
?>
<html>
<head>
<title>MartFitness</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script language="JavaScript1.1">// <![CDATA[
var specifyimage=new Array()
specifyimage[0]="images/1.png"
specifyimage[1]="images/2.png"
specifyimage[2]="images/3.png"
var delay=5000
var count =1;
var cubeimage=new Array()
for (i=0;i<specifyimage.length;i++){
cubeimage[i]=new Image()
cubeimage[i].src=specifyimage[i]
}
function movecube(){
if (window.createPopup)
cube.filters[0].apply()
document.images.cube.src=cubeimage[count].src;
if (window.createPopup)
cube.filters[0].play()
count++;
if (count==cubeimage.length)
count=0;
setTimeout("movecube()",delay)
}
window.onload=new Function("setTimeout('movecube()',delay)")
// ]]></script>
</head>
<body>
<center>
<img src="images/head.png"><p>
</center>
<center><div id="box">
<div id="images">
<img src="images/1.png" name="cube">
</div>
<div id="login">
<center>
<img src="images/login.png">
<br/><br/><br/>
<form action="ingreso.php" method="post">
<table>
<tr>
<td><img src="images/usuario.png"></td><td><input type="text" name="username" size="20" maxlength="30" /></td>
</tr>
<br/>
<tr>
<td><img src="images/pass.png"></td><td><input type="password" name="password" size="20" maxlength="20" /></td>
<?php if ( isset($_GET['error']) ): ?>
<div id="error">
Debes introducir tu password
</div>
<?php endif ?>
<?php if ( isset($_GET['err']) ): ?>
<div id="error">
Nombre de usuario o password incorrectos.
</div>
<?php endif ?>
<?php if ( isset($_GET['register']) ): ?>
Tu cuenta ha sido exitosamente creada.
<?php endif ?>
</tr>
<br/>
<tr>
<td><input type="submit" value="Ingresar" /></td> <td></td>
</tr>
</table>
<br/>
<a href="registrar.php"><img src="images/registrate.png"></a>
</form>
</center>
</div>
</div></center>
</body>
</html>
base.php
Insertar CODE, HTML o PHP:
<?php
$host = "localhost";
$user = "root";
$pw = "";
$bd = "martfitness";
$link = mysql_connect($host,$user,$pw);
mysql_select_db($bd,$link);
function isLogged() {
return !empty($_SESSION['s_username']);
}
?>
registrar.php
Insertar CODE, HTML o PHP:
<?php
?>
<html>
<head>
<title>Registro | MartFitness</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script language="JavaScript1.1">// <![CDATA[
var specifyimage=new Array()
specifyimage[0]="images/1.png"
specifyimage[1]="images/2.png"
specifyimage[2]="images/3.png"
var delay=5000
var count =1;
var cubeimage=new Array()
for (i=0;i<specifyimage.length;i++){
cubeimage[i]=new Image()
cubeimage[i].src=specifyimage[i]
}
function movecube(){
if (window.createPopup)
cube.filters[0].apply()
document.images.cube.src=cubeimage[count].src;
if (window.createPopup)
cube.filters[0].play()
count++;
if (count==cubeimage.length)
count=0;
setTimeout("movecube()",delay)
}
window.onload=new Function("setTimeout('movecube()',delay)")
// ]]></script>
</head>
<body>
<center>
<img src="images/head.png"><p>
</center>
<center><div id="box">
<div id="images">
<img src="images/1.png" name="cube">
</div>
<div id="login">
<center>
<img src="images/registro.png">
<form action="registro.php" method="post">
<table>
<tr>
<td><img src="images/usuario.png"></td><td><input type="text" name="username" size="20" maxlength="30"/></td>
</tr>
<br/>
<tr>
<td><img src="images/pass.png"></td><td><input type="password" name="password" size="20" maxlength="20"/></td>
</tr>
<br/>
<tr>
<td><img src="images/pass2.png"></td><td><input type="password" name="cpassword" size="20" maxlength="20"/></td>
</tr>
<br/>
<tr>
<td><img src="images/email.png"></td><td><input type="text" name="email" size=20 maxlength="40"/></td>
<?php if ( isset($_GET['err']) ): ?>
Un campo esta vacio.
<?php endif ?>
<?php if ( isset($_GET['error']) ): ?>
Las contraseñas no coinciden
<?php endif ?>
<?php if ( isset($_GET['error2']) ): ?>
EL nombre de usuario o la cuenta de correo estan ya en uso
<?php endif ?>
</tr>
<br/>
<tr>
<td><input type="submit" value="Registrar" /></td> <td></td>
</tr>
</table>
<br/>
<a href="index.php"><img src="images/ingresar.png"></a>
</form>
</center>
</div>
</div></center>
</body>
</html>
style.css
Insertar CODE, HTML o PHP:
* {
margin-top: 0px;
margin-bottom: 0px;
}
body {
background-image: url("images/bg.png");
}
#box {
background-color: white;
border: 3px solid;
width: 800px;
height: 350px;
position: relative;
margin-top: 20px;
margin-bottom: 20px;
}
#big {
background-color: white;
border: 3px solid;
width: 800px;
height: 900px;
position: relative;
margin-top: 20px;
margin-bottom: 20px;
}
#error {
width: 150px;
height: 200px;
background-color: grey;
border: 1px solid;
}
#perfil {
background-color: white;
border: 3px solid;
width: 150px;
height: 50px;
position: relative;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 93px;
}
#foto {
position: relative;
margin-top: 0px;
margin-bottom: 0px;
}
#images {
margin-top: 0px;
margin-bottom: 0px;
position: fixed;
}
#login {
margin-left:275px;
}
ingreso.php
Insertar CODE, HTML o PHP:
<?php
session_start();
include("base.php");
if ($_POST['username']) {
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
header( 'Location: index.php?error=1' );
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
header( 'Location: index.php?err=1' );
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
echo "Has sido logueado correctamente ".$_SESSION['s_username']." <script language=javascript>
window.location='home.php';</script>";
}
}
}
?>
registro.php
Insertar CODE, HTML o PHP:
<?php
include("base.php");
if (isset($_POST["username"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$email = $_POST["email"];
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
header( 'Location: registrar.php?err=1' );
}else{
// ¿Coinciden las contraseñas?
if($password!=$cpassword) {
header( 'Location: registrar.php?error=1' );
}else{
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$email_exist = mysql_num_rows($checkemail);
if ($email_exist>0|$username_exist>0) {
header( 'Location: registrar.php?error2=1' );
}else{
$query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')";
mysql_query($query) or die(mysql_error());
header( 'Location: index.php?register=1' );
}
}
}
}
?>
home.php
Insertar CODE, HTML o PHP:
<?php
session_start();
include("base.php");
if ( !isLogged() ) {
header('Location: index.php');
}
?>
<html>
<head>
<title>Home | MartFitness</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
<center>
<img src="images/head.png"><p>
</center>
<div id="perfil">
<div id="foto">
<img src="images/perfil.jpg">
<a href="logout.php">Cerrar Seccion</a>
<br/><br/>
</div>
</div>
<center><div id="big">
<div id="images">
</div>
<div id="login">
</div>
</div></center>
</body>
</html>
logout.php
Insertar CODE, HTML o PHP:
<?php
session_start();
session_destroy();
?>
<script language=javascript>
location.href='index.php';
</script>
Lo que quiero hacer:
-Que cada usuario que se registre, automaticamente se le cree una pagina de su perfil, en donde pueda elegir una foto o cambiar los datos de su cuenta, y luego que en cada pagina que ande por la web lo reconozca por su usuario.
como lo podria hacer? gracias 😀