Jump to content

Recommended Posts

This is my code:

 

// Variables
$name = $_POST['name'];
$dname = $_POST['display_name'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$email = $_POST['email'];
$age = $_POST['age'];
$dob = $_POST['dob'];
$country = $_POST['country'];
$location = $_POST['location'];
$website = $_POST['website'];
$aim = $_POST['aim'];
$msn = $_POST['msn'];
$yim = $_POST['yim'];
$icq = $_POST['icq'];
$info = $_POST['info'];
$games = $_POST['games'];
$interests = $_POST['interests'];

// Query
$q = mysql_query("SELECT * FROM `pcp_users` WHERE username = '$username' || email = '$email'");
$r = mysql_fetch_array($q);
if(($r['username'] == $username) || ($r['email'] == $email)) {
    header("Location: " . $site_url . "index.php?p=register&e=1");
}
if(($name == "") || ($dname == "") || ($username == "") || ($password == "") || ($email == "")) {
    header("Location: " . $site_url . "index.php?p=register&e=2");
}
mysql_query("INSERT INTO `pcp_users` (username,password,email,display,name,description,age,dob,country,location,interest,website,aim,msn,icq,yim,games) VALUES ('$username','$password','$email','$dname','$name','$info','$age','$dob','$country','$location','$interests','$website','$aim','$msn','$icq','$yim','$games')") or die (mysql_error());
header("Location: " . $site_url . "index.php?p=login&e=4");

 

Now using that code, the header header("Location: " . $site_url . "index.php?p=login&e=4"); messes up the code, but if I comment that line out, then the code works fine. If I use it it forwards to " . $site_url . "index.php?p=login&e=4 when I am leaving form fields blank, but if I comment it out the, it corretly forwards it to " . $site_url . "index.php?p=register&e=2.

 

Whats wrong? Thanks

Link to comment
https://forums.phpfreaks.com/topic/74650-solved-help/
Share on other sites

use if / ifelse statements so it only executes the header you want.

 

Something like:

 

<?php
if(($r['username'] == $username) || ($r['email'] == $email)) {
    header("Location: " . $site_url . "index.php?p=register&e=1");
}

elseif(($name == "") || ($dname == "") || ($username == "") || ($password == "") || ($email == "")) {
    header("Location: " . $site_url . "index.php?p=register&e=2");
}
else {
mysql_query("INSERT INTO `pcp_users` (username,password,email,display,name,description,age,dob,country,location,interest,website,aim,msn,icq,yim,games) VALUES ('$username','$password','$email','$dname','$name','$info','$age','$dob','$country','$location','$interests','$website','$aim','$msn','$icq','$yim','$games')") or die (mysql_error());
header("Location: " . $site_url . "index.php?p=login&e=4");
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/74650-solved-help/#findComment-377336
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.