Foros del Web » Programando para Internet » PHP »

no entiendo.

Estas en el tema de no entiendo. en el foro de PHP en Foros del Web. para hacer un signup o registro como le coloco los script de aqui abajo: todo esto lo salvo como registro.php? --------------------------------------------- <form name=registration action="signup.php" method="get"> ...
  #1 (permalink)  
Antiguo 13/11/2002, 15:30
fosforito
Invitado
 
Mensajes: n/a
Puntos:
no entiendo.

para hacer un signup o registro como le coloco los script de aqui abajo:

todo esto lo salvo como registro.php?
---------------------------------------------
<form name=registration action="signup.php" method="get">
Username:
<input name="signupusername" type="text" width="10"><BR>
Password:
<input name="signuppassword" type="password" width="10"><BR>
Verify your password:
<input name="signuppasswordverify" type="password" width="10"><BR>
Email Address:
<input name="emailaddress" type="text" width="10"><BR>
<INPUT TYPE=SUBMIT VALUE="Sign Up">
</form>
------------------------------------------------------------

y para la funcion le salvo con un nombre de archivo aparte?
o esque va todo en uno ,el de arriva con este de abajo?
--------------------------------------------
<?
// User Sign Up PHP Script
//
// This script validates information, saves it to the database
// displays it to them
// and sends it to them via email
//
// vars:
// $signupusername
// $signuppassword
// $signuppasswordverify
// $signupemailaddress
//
// Note have to use signup* vars initially to make it
// clear to ourselves that
// we're dealing with signupotherwise

// Include common variables and message text
// include 'zcommon.php';
// Normally these would come from an include file. Since this is
// an example, we'll just put them here:
// db login parameters

$dbhost = "localhost";
$dbuser = "mysqluser";
$dbpassword = "password";
$db = "dbname";
$sysadminemail = "youremail";


// null out cookies if new user
// null out cookies at start of sign in routine
// all cookies begin with "ck_" to indicate that they are a cookie
// helps troubleshoot mysterious cookie errors
// note on using cookies.
// MUST BE SET before ANY http output.
// They TRAVEL in the http HEADER so have to go first.
setcookie ("ck_user", "");
setcookie ("ck_password", "");
setcookie ("ck_user_id", "");

// 0th check that passwords match
if($signuppassword!=$signuppasswordverify) {
create_error_page_passwordsnotmatch();
}
else {
// their passwords match so enter next validation stage
// first test that their username isn't already in use

// Connecting, selecting database
$link = mysql_connect("$dbhost", "$dbuser", "$dbpassword")
or die("Could not connect");
// select the database
mysql_select_db("$db")
or die("Could not select database");
// try and select the username that the user entered to see if
// it is already in the db
$query = "SELECT username "
. " FROM users "
. " WHERE username='$signupusername'";

$result = mysql_query($query)
or die("Query failed at username unique testing stage.");

// logic -- if the num_rows is 1 then the username is already
// in use and they have to choose another
$num_rows = mysql_num_rows($result);
// don't need to get it -- its the same as what we already have

// num_rows can't ever be >= to 1 since unique constraint
// on the column of data
if ($num_rows == 1) {
create_error_page_usernameinuse();
}
else {
// NOTE -- Depending on how you want to define
// a valid password (5 chars, 6 chars
// plus a number, etc), that would go here

//Capture the ipaddress and call MD5
$ipaddress = getenv ("REMOTE_ADDR");
$encryptedpassword = md5($signuppassword);

//try and add them to the database
$query = "INSERT INTO users "
. " ( username, password, date, ipaddress ) "
. " VALUES ('$signupusername','$encryptedpassword', "
. " NOW(), '$ipaddress')";

//execute the query
$result = mysql_query($query)
or die("Query failed at user insertion stage.");

//now query the db back for the user_id variable
$query = "SELECT user_id "
. " FROM users "
. " WHERE username='$signupusername'";

// get the result
$result = mysql_query($query)
or die("Query failed at userid retrieval stage.");

//get the user_id from the result
$num_rows = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$user_id = $row[0];

// send the cookies now. MUST BE FIRST THING OUTPUT
setcookie ("ck_username", "$signupusername");
setcookie ("ck_password", "$signuppassword");
setcookie ("ck_user_id", "$user_id");

//Define the $title variable for the page title
$title = "Thanks for Signing Up!";

//Set up the page header
PrintPageHeader("$title");

//Print out the body of the page
// Note that some basic html formatting is used
// here to make it look better

print "<TABLE WIDTH=728 BGCOLOR=WHITE><TR><TD>";
print "<H1>Thank You...</H1>";
print "<HR>";
print "<CENTER>Thanks for playing! ";
print "Seriously, we appreciate your signing";
print "up.</CENTER><BR><BR>";
print "Here is the information that you entered:";
print "<UL>";
print "<LI>Username: $signupusername</LI>";
print "<LI>Password: $signuppassword</LI>";
print "<LI>Email Address: $emailaddress</LI>";
print "</UL>";
print "<BR>We have also emailed this to the email ";
print "address you gave us.<BR>";
print "</TD>";
print "</TR>";
print "<TABLE>";

//Usually you want to add a link to your
// application's home page here.
// Left as an exercise for the reader.

//handle sending out the email if we got an email address!
if ($emailaddress != "") {
// compose the email
$to = $emailaddress;
$subject = "Your IMSaver Account";
$message = "Hi there, "
. "Your account has been created and is ready for use."
. ""
. ""
. "Your username is: $signupusername"
. "Your password is: $signuppassword"
. ""
. "Thanks for signing up for YOURNAMEHERE."
. "http://YOURURLHERE/"
. ""
. "YOURNAMEHERE";
// send the email
mail($to, $subject, $message, "From: [email protected]", "[email protected]");
}

//Set up the footer of the page
PrintPageFooter("");
}
}

// start of functions

function PrintPageHeader ($title) {
print "<HTML>";
print "<HEAD>";
print "<TITLE>";
print "$title";
print "</TITLE>";
print "</HEAD>";
print "<BODY>";
}

function PrintPageFooter ($title) {
print "</BODY>";
print "</HTML>";
}


function create_error_page_passwordsnotmatch() {
//Define the $title variable for the page title
$title = "We're Sorry But You're Passwords Don't Match!";

//Set up the page header
PrintPageHeader("$title");

print "<TABLE WIDTH=728 BGCOLOR=WHITE><TR><TD>";
print "<H1>We're Sorry...</H1>";
print "<HR>";
print "<BR>";
print "We're sorry but You didn't enter matching passwords. ";
print "&nbsp;Please make sure that you enter your password ";
print "in the Password field and the Verify Password fields ";
print "and that both are the same.<BR><BR>";
print "Please press the back button and make sure that the ";
print "passwords match.";

// close container table
print "</TD></TR></TABLE>";

//Set up the footer of the page
PrintPageFooter("");
}


function create_error_page_usernameinuse() {
//Define the $title variable for the page title
$title = "We're Sorry But that Username is Already in Use...";

//Set up the page header
PrintPageHeader("$title");

print "<TABLE WIDTH=728 BGCOLOR=WHITE><TR><TD>";

print "<H1>We're Sorry...</H1>";
print "<HR>";
print "<BR>You entered a Username that another person is using";
print "<BR>Press Back to try again.";
// close container table
print "</TD></TR></TABLE>";

//Set up the footer of the page
PrintPageFooter("");
}

?>


o esque todo los script le hago en uno solo y le salvo como registrarse.php no se si me entendieron.
  #2 (permalink)  
Antiguo 13/11/2002, 15:51
Avatar de chubu  
Fecha de Ingreso: enero-2002
Ubicación: Buenos Aires
Mensajes: 133
Antigüedad: 22 años, 2 meses
Puntos: 0
Serían dos scripts diferentes, el de abajo seria signup.php (lo dice en el action del primer form ;)), y el primero ponle el nombre que te parezca, registro.php estaria bien.

saludos,

chubu
__________________
:pensando:hay algo mal que no anda bien
  #3 (permalink)  
Antiguo 13/11/2002, 16:00
Avatar de jnegro  
Fecha de Ingreso: diciembre-2001
Ubicación: Salta
Mensajes: 238
Antigüedad: 22 años, 4 meses
Puntos: 0
no es un solo archivo

<form name=registration action="signup.php" method="get">
ahí le estás dicendo que el archivo donde está el script que procesará la petición se llama signup.php

en el archivo signup.php:
tenés que configurar con los datos de tu base lo siguiente
Código PHP:
$dbhost "localhost"// el nombre del servidor mysql ( en general es "localhost" 
$dbuser "mysqluser";// nombre de usuario mysql
$dbpassword "password";contraseña de usuario mysql
$db 
"dbname";//nombre de la base de datos
$sysadminemail "youremail"// tu correo 
importante:
Código PHP:
$query "INSERT INTO users "
" ( username, password, date, ipaddress ) " 
en la base mysql tiene que haber una tabla "users" con los campos "username,password,date,ipadress"
y no deberías olvidar configurar las variables del mail para que lo mande:
"http://YOURURLHERE/" tu URL, "YOURNAMEHERE" el nombre de tu sitio, etc.

Espero que te sirva de ayuda

Éxitos.
  #4 (permalink)  
Antiguo 13/11/2002, 16:04
fosforito
Invitado
 
Mensajes: n/a
Puntos:
Gracias chubu!
No sabes como me esta dando dolor de cabeza esto, espero que con tu ayuda pueda solucionarlo, y nuevamente gracias lo probare ahora mismo ,chau!!
  #5 (permalink)  
Antiguo 13/11/2002, 16:15
fosforito
Invitado
 
Mensajes: n/a
Puntos:
hola jnegro .

sabes hice eso, cree una base de datos que se llama members y use members para crear la tabla de users que contiene su name password etc..
hasta ahi me sale todo bien, el problema es cuando pongo todo los scrips en php, como les hacia la pregunta ahi arriba, nose como guadarlos los archivos, no se si es como dice chubu

para conectame a mysql pongo todo lo correcto localhost mi username y mi passwor etc..

cuando le pongo a prueva me sale error.
pero talves es por esto no me havia fijado

"http://YOURURLHERE/" tu URL, "YOURNAMEHERE"

lo voy a probar haver que sale, gracias jnegro,
saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:00.