Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:34:36+00:00 2026-06-05T19:34:36+00:00

I have a very simple script that creates a user: <?php include ‘mysqlserver.php’; session_start();

  • 0

I have a very simple script that creates a user:

<?php
include 'mysqlserver.php';
session_start();



$con = mysql_connect($mysql_host, $mysql_username,$mysql_password);
if (!$con) {
die('Could not connect: ' . mysql_error());
}


mysql_select_db($mysql_db, $con);

$newuser = $_POST[username];
$newpassword = $_POST[password];
$confirmnewpassword = $_POST[confirmpassword];

if ($newpassword != $confirmnewpassword) {
die('Passwords do not match.');
}

if ($newuser == null) {
die('You need to choose a username!');
} elseif ($newpassword == null) {
die('You need to enter a password!');
}

$avail_query = mysql_query("SELECT * FROM users WHERE username='$newuser'");

$avail_numrows = mysql_num_rows($avail_query);

if ($avail_numrows != 0) {
die('That user already exists');
}


mysql_query("INSERT INTO users (username, password) 
VALUES ('$newuser', '$newpassword')");


$_SESSION['username'] == $newuser;

mysql_close($con);
?>

<script type="text/javascript">

function enterUCP(){
window.location = "/member.php"
}

</script>
</head>
<body onLoad="setTimeout('enterUCP()', 3000)">
Account created! Logging you in...
</body>

Originally, my script simply redirected you to the login page after creating an account. I’ve been trying to tweak it so you are logged in after the creation of an account.
For some reason, I cannot edit $_SESSION[‘username’] or any other session variables, even though I have started the session on line 3. I’m very confused, as some of my other PHP scripts properly manipulate $_SESSION variables, and I can’t tell what’s different in mine.

P.S. Please don’t comment on the security of my system. It’s probably terribly insecure, but I’m just writing for a prototype.

EDIT: Just to make this a little less useless of a question, can anyone find any serious security flaws here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:34:37+00:00Added an answer on June 5, 2026 at 7:34 pm

    Change:

    $_SESSION['username'] == $newuser;
    

    to:

    $_SESSION['username'] = $newuser;
    

    You’re comparing instead of setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple php ldap script that is only failing when running
I have a very simple js script that works for hovers, but I want
I have a very simple python script that should scan a text file, which
I have written a very very very simple!! script in php. header redirection not
I have a php script that does some processing (creates remittance advice PDFs, self-billing
At the moment I have a very simple script. If I type the commands
I have a very simple jQuery script.. all I want it to do is
I have a very simple Powershell v1.0 script to kill processes by name: $target
I have very simple XML in a string that I'm trying to load via
I have a very simple user model. When I first created it, it had

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.