Jump to content

Undefined index's


dean7

Recommended Posts

Hi all, I'm currently adding something to my website which makes the user input some information before they enter the site, but I'm getting errors saying..

 

Notice: Undefined index: realname in /home/a5908246/public_html/next.php on line 24

Notice: Undefined index: gamer in /home/a5908246/public_html/next.php on line 48

 

But with them errors its not showing the actual form where you post the info into.

 

<?php
session_start();
include ("includes/config.php");
include ("includes/functions.php");
logincheck();

ini_set ('display_errors', 1);
error_reporting (E_ALL);

$username = $_SESSION['username'];

$get = mysql_query ("SELECT * FROM users WHERE username='$username'") or die (mysql_error());
$got = mysql_fetch_object($get);

?>
<html>
<head>
<title>Please Update..</title>
</head>
<body>
<form action='' method='POST' name='everything'>
<?php 
if ($got->realname == ''){
if ($_POST['realname']){ // Line 24
$input = $_POST['nameinput'];
?>
<table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'>
<tr>
<td class='e_header' align='center'>Error!</td>
</tr>
<tr>
<td class='omg' align='center'>Please Enter your Real Name.</td>
</tr>
<tr>
<td align='center'><input type='text' name='nameinput' class='textinput'></td>
</tr>
<tr>
<td align='center'><input type='button' name='realname' class='button' Value='Update Name!'></td>
</tr>	
</table>
<br />	
<?php
mysql_query ("UPDATE users SET realname='$input' WHERE username='$username'") or die (mysql_error());
}}
?>
<?php
if ($got->gamertag == ''){
if ($_POST['gamer']){ // Line 48
$inputgamer = $_POST['gamertag'];
?>
<table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'>
<tr>
<td class='e_header' align='center'>Error!</td>
</tr>
<tr>
<td class='omg' align='center'>Please Enter your Gamertag.</td>
</tr>
<tr>
<td align='center'><input type='text' name='gamertag' class='textinput'></td>
</tr>
<tr>
<td align='center'><input type='button' name='gamer' class='button' Value='Update Gamertag!'></td>
</tr>	
</table>
<?php
mysql_query ("UPDATE users SET gamertag='$inputgamer' WHERE username='$username'") or die (mysql_error());
}}	

if ($got->realname != '' || $got->gamertag != ''){
// Display, welcome $realname, redirecting you to main site now... (2 seconds waiting)
?>
<table width='50%' border='1' class='tableborder2' cellspacing='1' align='center'>
<tr>
<td class='header' align='center'>Welcome!</td>
</tr>
<tr>
<td class='omg' align='center'>Welcome!</td>
</tr>
<tr>
<td align='center'>You will be redirected to the main site in 2 seconds!<meta http-equiv="refresh" content="2;url=http://******.com/index2.php"></td>
</tr>	
</table>
</form>
<?php
}
?>

 

Thanks for any help/advice given :)

Link to comment
https://forums.phpfreaks.com/topic/229121-undefined-indexs/
Share on other sites

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.