TinyPortal

Development => Support => Topic started by: alienv on February 17, 2007, 03:09:44 PM

Title: "8: Undefined index" in PHP articles
Post by: alienv on February 17, 2007, 03:09:44 PM
Hi
i've created phparticle with small form (post).
There's a submit button and a text input

And everytime someone click button i've got error report in admin
it looks like :
8: Undefined index: submit_register
File: /path/to/forum/Themes/default/TPortal.template.php (main sub template - eval?)
Line: 5


It's a way to fix it ? or at least stop reporting errors ?? ::)
Or i need to create my own module for it...

Thnx in advance
Title: Re: "8: Undefined index" in PHP articles
Post by: Lesmond on February 17, 2007, 04:28:24 PM
you could post your code, then maybe someone will come along and see whats wrong, (not me though :idiot2: when it comes to code)
Title: Re: "8: Undefined index" in PHP articles
Post by: alienv on February 22, 2007, 03:00:51 PM
i can but i doubt that there's something mesed up with the code..
howeverm here is part of code.

global $user_info;
echo '<div align="center">
<form name="register" method="post" action="">
<table>';
if ( $_POST['submit_register'] )
{
[...]
echo '<tr><td align="right">Login</td><td><input type="text" name="login" value="' . $user_info['username'] . '"/></td></tr>
<tr><td align="right">E-Mail</td><td><input type="text" name="email" value="' . $user_info['email'] . '"/></td align="right"></tr>
[...]
<tr><td colspan="2" align="center"><input type="submit" name="submit_register" value="Register" /></td></tr>
</table>
</form>
</div>';

(and i don't use $_POST['submit_register'] somewhere else)
Title: Re: "8: Undefined index" in PHP articles
Post by: Lesmond on February 22, 2007, 03:07:56 PM
umm I have read that somewhere! something about  method="post" where it tries to post to your forum, but I cant find the topic!
Title: Re: "8: Undefined index" in PHP articles
Post by: JPDeni on February 22, 2007, 03:12:40 PM
Try changing


if ( $_POST['submit_register'] )


to


if ( isset($_POST['submit_register']) )


It doesn't like the fact that it's looking for the value $_POST['submit_register'], when it's not been defined at all. If you change your "if" statement to check whether the value has been set, the program will be happy.

I run into this all the time. :)