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 6917059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:40:56+00:00 2026-05-27T09:40:56+00:00

<?php function redirect_to_index_with_error(){ echo ‘<meta http-equiv=refresh content=0;url=index.php>’; } function go_to_home(){ echo ‘<meta http-equiv=refresh content=0;url=home.php>’;

  • 0
<?php

function redirect_to_index_with_error(){
    echo '<meta http-equiv="refresh" content="0;url=index.php">';
}

function go_to_home(){
    echo '<meta http-equiv="refresh" content="0;url=home.php">';
}

$email = mysql_real_escape_string($_POST['username']); echo $email;
$pwd = mysql_real_escape_string($_POST['password']);
echo $pwd;
$query = "SELECT * FROM users WHERE email='$email' AND password=MD5('$pwd')";
echo "query variable created.";

mysql_connect("localhost","root","") or die(mysql_error());
echo "connected."; //nothing

mysql_select_db("mcp") or die(mysql_error());

$results = mysql_query($query) or die(mysql_error());

if(mysql_num_rows($results) == 0){
    redirect_to_index_with_error();
    exit();
}

$userID = null;
$name = null;
$school = null;
$mod = null;

while($user = mysql_fetch_array($results)){
    $userID = $user['ID'];
    $name = $user['Name'];
    $school = $user['School'];
    if($user['Mod'] == '1')
        $mod = true;
    else
        $mod = false;

}
if(!isset($_SESSION))
    session_start();

//set session variables
$_SESSION["userID"] = $userID;
$_SESSION["name"] = $name;
$_SESSION["school"] = $school;
$_SESSION["mod?"] = $mod;

go_to_home();
exit();
?>

PHP echos everything up until “connected”. It’s not even showing a mysql error. I’ve had this code work flawlessly on Windows with WAMP, but not on Mac with MAMP. I’ve verified that the servers are running, so I can’t tell what the problem is. I’m using PHP 5.3.6.

  • 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-05-27T09:40:57+00:00Added an answer on May 27, 2026 at 9:40 am

    Your connection needs to be established before you call mysql_real_escape_string()

    So move mysql_connect("localhost","root","") or die(mysql_error()); to the top.

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

Sidebar

Related Questions

My module in Magento adminpanel has URL like as http://example.com/index.php/mymodule/ ... and contains custom
I want to redirect page like: http://www.mysite.com/index.php?id=1 to http://www.mysite.com/the-real-name.htm but I don’t have the-real-name
I'm using the PHP function imagettftext() to convert text into a GIF image. The
Is there a Php function to determine if a string consist of only ASCII
I have a php function I wrote that will take a text file and
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
Is there a php function that someone can use to automatically detect if an
I have written a PHP function to take a video embed code that has
Below is an old PHP function I have for a dropdown list for users
I have a PHP function that takes a variable number of arguments (using func_num_args()

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.