jrws Posted December 23, 2008 Share Posted December 23, 2008 I have a script I am using, and as I am a beginer at PHP and OOP the code may have problems. I am trying to make an install page. So far it worked until I added the option of adding an admin via the install page. There are no user levels as of yet and so it was a test. Heres the problem; I click submit and the form processes without going to another page, and the administrator is added, however the email is not there, I even echoed what the database thouht was happening and this is what I got: INSERT INTO `site`.`user` ( `id` , `username` , `password` , `email` ) VALUES ( NULL , 'test', '68358d5d9cbbf39fe571ba41f26524b6', '' ); Now I can't figure out why, because when all forms are filled in that is the same continuous result. I've checked my code to make sure I got the names right,I do. I have also checked that the functions don't interfer with the code, and they don't. So now I am lost. Finially here is the code: <?php $user = clean($_POST['user']); $email = clean($POST['email']); $password = clean($_POST['password']); $password = encrypt($password); $Add_Admin = "INSERT INTO `site`.`user` ( `id` , `username` , `password` , `email` ) VALUES ( NULL , '$user', '$password', '$email' ); "; if ($mysql->query($Add_Admin)) { echo 'Admin user created succesfully!<br>'; echo $Add_Admin; } else { echo 'Admin user failed to be created!<br>'; }?> PHP tags added for the sake of adding them. Heres the form: <form method="post" action="<? $SERVER_['PHP_SELF']; ?>"> Admin Name: <input type="text" name="user"> <br> Password: <input type="password" name="password"><br> Email:<input type="text" name="email"><br> <input type="submit" name ="submit" value="Submit"> </form> When I said error_reporting(E_ALL) the only error I got was with the $SERVER variable... If there is anything else you need to help me solve my problem please ask. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/ Share on other sites More sharing options...
trq Posted December 23, 2008 Share Posted December 23, 2008 When I said error_reporting(E_ALL) the only error I got was with the $SERVER variable... First thing Id do is fix that then. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Also, where is $mysql created? Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721901 Share on other sites More sharing options...
jrws Posted December 23, 2008 Author Share Posted December 23, 2008 Sorry I don't understand what you mean by where it it created? Do you mean where at the script? At the very top: require_once ('config.php'); $mysql = new mysql(); Config has the autoload function, and I will try your suggestion Just tried it, no change. BTW why do you add echo anyway? I have seen it done many times and now I am interested as to why, because just the server variable seems to work for me... Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721913 Share on other sites More sharing options...
trq Posted December 23, 2008 Share Posted December 23, 2008 because just the server variable seems to work for me... It might on your setup but it can be disabled, hence, using it makes your code less portable. You should always use the complete <?php ?> tags too. Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721919 Share on other sites More sharing options...
MadTechie Posted December 23, 2008 Share Posted December 23, 2008 if short tag (<? ) are not enable the code won't work and with long tags (<?php ) you need the echo.. but thats not the problem you had you had $SERVER_['PHP_SELF']; the correct syntax is $_SERVER['PHP_SELF']; note the underscore position .. in anycase.. can you change this line $email = clean($POST['email']); to $email = clean($_POST['email']); thats should fix it Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721921 Share on other sites More sharing options...
trq Posted December 23, 2008 Share Posted December 23, 2008 Actually looking again. <? $_SERVER['PHP_SELF']; ?> won't work either. You would need to use <?= $_SERVER['PHP_SELF']; ?> (which I still wouldn't recommend). Your code would actually produce a blank action which as it be happens to default to the calling page. Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721922 Share on other sites More sharing options...
jrws Posted December 23, 2008 Author Share Posted December 23, 2008 Alright thanks, I thought I was forgetting something simple. Thanks again for your help, it works now Quote Link to comment https://forums.phpfreaks.com/topic/138101-solved-i-cant-find-the-error-please-help/#findComment-721938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.