Sign in to follow this  
Followers 0

Simple script, but why doesn't it work?

4 posts in this topic

<?php session_start();require 'config.php'; // Dołącz plik konfiguracyjny i połączenie z bazarequire_once 'user.class.php'; if ($_POST['register'] == 1) {    // Zabezpiecz dane z formularza przed kodem HTML i ewentualnymi atakami SQL Injection    $login = mysql_real_escape_string(htmlspecialchars($_POST['login']));    $pass = mysql_real_escape_string(htmlspecialchars($_POST['pass']));    $pass_v = mysql_real_escape_string(htmlspecialchars($_POST['pass_v']));    $email = mysql_real_escape_string(htmlspecialchars($_POST['email']));    $login = mb_strtolower($login);     $existsLogin = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM accounts WHERE login='$login' LIMIT 1"));    $existsEmail = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM accounts WHERE email='$email' LIMIT 1"));    $errors = '';       if (!$login || !$email || !$pass || !$pass_v ) $errors .= '- Musisz wypelnić wszystkie pola<br />';    if ($existsLogin[0] >= 1) $errors .= '- Ten login jest zajety<br />';    if ($existsEmail[0] >= 1) $errors .= '- Ten e-mail jest juz uzywany<br />';    if ($pass != $pass_v)  $errors .= '- Hasla sie nie zgadzaja<br />';    if ($errors != '') {        echo '<p class="error">Rejestracja nie powiodla sie, popraw nastepujace bledy:<br />'.$errors.'</p>';    }     else {          mysql_query("INSERT INTO accounts (login, password, email, status, reason) VaLUES('$login','$pass','$email','OK', '---')") or die ('mysql error');         echo '<p class="success">'.$login.', zostales zarejestrowany.        <br />Teraz mozesz sie zalogowac.';    }} if (!user::isLogged()) { echo' <div class="col-md-12"><div class="itemshop"><form method="post" action=""> <div class="form-group"><center><label>Login</label></center><input name="login" type="text" class="form-control" placeholder="Login"> </div>  <div class="form-group"><center><label>Password</label></center><input name="pass" type="password" class="form-control" placeholder="Password"> </div>  <div class="form-group"><center><label>Re-Password</label></center><input name="pass_v" type="password" class="form-control" placeholder="Re-Password"> </div>  <div class="form-group"><center><label>E-Mail</label></center><input name="email" type="text" class="form-control" placeholder="E-Mail"> </div> <center><button name="register" type="submit" class="btn btn-xs btn-primary">Register</button></center></form></div></div>';};  ?>

Share this post


Link to post
Share on other sites
require 'config.php'; // Dołącz plik konfiguracyjny i połączenie z bazarequire_once 'user.class.php';

 

I'm not gonna be able to test it without these files and I'm not gonna bother to read the code line by line.

Share this post


Link to post
Share on other sites

I've fixed it, you didnt have to, really

i had to replace

if ($_POST['register'] == 1) {

to

if (isset($_POST['register'])) {

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0