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
https://forums.phpfreaks.com/topic/177613-help-with-undefined-index/
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!

 

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.