SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Fatal error: Call to undefined function redirect_to()

    please i am getting this error : Fatal error: Call to undefined function redirect_to() in /home/reachea2/public_html/relogin.php on line 31(the login is meant to reirect to the index page)

    PHP Code:

    <?php

    session_start
    ();

    $username $_POST['username'];
    $password $_POST['password'];

    if (
    $username&&$password)
    {

    $connect mysql_connect("localhost","reachea2","HYW6QwoV"
    or die(
    "couldn't connect!");
    mysql_select_db("reachea2_registeringmembers") or die ("couldn't find db");

    $query mysql_query("SELECT * From reusers WHERE username='$username'"); 

    $numrows =mysql_num_rows($query);

    if(
    $numrows!=0)
    {
        while (
    $row mysql_fetch_assoc($query))
        {
            
    $dbusername $row['username'];
            
    $dbpassword $row['password'];
            
            
    // chect to see if they match!
            
    if ($username==$dbusername&&md5($password)==$dbpassword)
            {
            
    //echo " You are in! <a href='remembers.php'>Click</a> here to enter the member page";
            //echo " You are in! <a href='index.html'>Click</a> here to enter the member page";
            
    redirect_to('index.html');
            
            
    $_SESSION['username']=$username;
            }
            else
         echo 
    " incorrect password!";
            
        }
    }
    else
        die(
    "That user dosen't exist!");

    }
    else
        die(
    "Please enter a username and a password");

    ?>

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,036
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Looks like that function should have been defined somewhere.

    It's probably something like this:

    PHP Code:
    function redirect_to($location$status=302)
    {
       
    header('Location: '.$locationtrue$status);
       exit();

    Last edited by ScallioXTX; Oct 5, 2011 at 04:28. Reason: used wrong variable
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks scallio, i idefined it in the function as
    <?php
    //basic functions
    function redirect_to( $location = NULL ) {
    if ($location != NULL) {
    header("Location: {$location}");
    exit;
    }
    }

    ?>
    and it worked.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •