Jump to content

Help with undefined index!!!


renlfey

Recommended Posts

K guys im new here and in need of a quick fix!

 

im getting            Undefined index: success

error and here is my code!!

 

<?php

if($_get["success"] == "1")

{

echo "Thank you for registering, Your browser will soon be redirected our home page!";

}

else

{

include("../includes/RegistrationForm.php");

}

?>

 

Any input would be greatly apreciated!

Link to comment
Share on other sites

o i tried

 

<?php

        if $_GET["success"] == "1"

        {

            echo "Thank you for registering, Your browser will soon be redirected our home page!";

        }

-----------------------------------------

<?php

        $_GET["success"] == "1"

        {

            echo "Thank you for registering, Your browser will soon be redirected our home page!";

        }

-------------------------------------------------------------------------<?php

        if $_GET["success"] == "1";

        {

            echo "Thank you for registering, Your browser will soon be redirected our home page!";

        }

 

And im still getting the error any way you can elaborate??? Thx for you quick response!

 

Link to comment
Share on other sites

Is there a success being set? I am guessing that you are using a form and sending success as a variable of the form. If not, you need something like

 

if(isset($_GET['success']) && $_GET['success'] == "1") {
    echo "Thank you for registering, Your browser will soon be redirected our home page!";
}else{
    echo "Error";
}

Can you show your form as I am guessing you are not setting $_GET['success'] anywhere

Link to comment
Share on other sites

Success!! Genious i cant beleive i didnt think of that !

 

The form

<form action=register.php method=post>                   

            Username:<input name="username" size="30" autocomplete="off" value="" type="text" /><br /><br />

                Password:<input name="password" size="30" type="password" /><br /><br />

                First Name:<input name="firstname" size="30" type="text" /><br /><br />

                Last Name:<input name="lastname" size="30" type="text" /><br /><br />

                Email:<input name="email" size="30" type="text" /><br /><br />

                Age:<input name="age" size="30" maxlength="2" /><br /><br />

                <input type="submit" class="button" value="Register" />

                <input type="reset" name="reset" value="Clear" />

          </form> 

--------------------------------------------------------

the register.php

<?php

include 'mysql-connect.php';

$username = $_POST['username'];

$password = $_POST['password'];

$firstname = $_POST['firstname'];

$lastname = $_POST['lastname'];

$age = $_POST['age'];

$ip = $_SERVER['REMOTE_ADDR'];

 

$result = mysql_num_rows(mysql_query("SELECT * FROM wwd_users WHERE username='$username'"));

if($result == 1)

    {

    echo " <script>window.location=\"registration.php?success=0\"</script>";

    }

else

    {

    mysql_query("INSERT INTO wwd_users (username, password, firstname, lastname, age, ip)

VALUES ('$username', '$password', '$firstname', '$lastname', '$age', '$ip')");

 

 

echo " <script>window.location=\"registration.php?success=1\"</script>";

}

 

?>

--------------------------------------------------------------------

Thanks again seems to work now

Link to comment
Share on other sites

Ive set it but i think it still needed to be set in the

 

<?php

if(isset($_GET['success']) && $_GET['success'] == "1")

{

echo "Thank you for registering, Your browser will soon be redirected our home page!";

}

else

{

include("../includes/RegistrationForm.php");

}

?>

 

In order for it to be defined stince im its being set from another page! either way weve tested it and its the perfect solution! Thanks again

Link to comment
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.