Gayner Posted August 10, 2009 Share Posted August 10, 2009 Sorry for Double post, but I have a problem, im trying to do this but it just keep's refreshing: if ( $_POST['remove'] ) { mysql_query("UPDATE ibf_members SET avatar='". mysql_real_escape_string(' ') ."' WHERE id={$ibforums->member['id']}"); header("Location: index.php?act=UserCP&CODE=Avatar"); } if(isset($_POST['avatar'])){ $ext = explode ( "|", 'gif|jpeg|jpg|png' ); $checked = 0; $av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $_POST['avatar'] ); foreach ($ext as $v ) { if (strtolower($v) == strtolower($av_ext)) { $checked = 1; } } if ($checked != 1) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_ext' ) ); } mysql_query("UPDATE ibf_members SET avatar='". mysql_real_escape_string($_POST['avatar']) ."' WHERE id={$ibforums->member['id']}"); header("Location: index.php?act=UserCP&CODE=Avatar"); } MY HTML IS: <form name="form" method="post"> <input type="text" size=50 name="avatar" value="{$ibforums->member['monkavatar']}"> <input type="Submit" value="Update Avatar"> | <input type="submit" name="remove" value="Remove Avatar"> Now whenever I click on Remove Avatar it just refreshes my page, the name for The Remove avatar submit is "remove" it should follow my $_POST['remove'] right? it's not Quote Link to comment Share on other sites More sharing options...
Maknis Posted August 10, 2009 Share Posted August 10, 2009 Your form has no action? should it not have an action so it knows where to go to process the php? Quote Link to comment Share on other sites More sharing options...
halfman Posted August 10, 2009 Share Posted August 10, 2009 you need to change this <input type="submit" name="remove" value="Remove Avatar"> to <input type="button" name="remove" value="Remove Avatar" onclick ="Put the javascript in here"> or make another form that passes the id to remove or update the databse as 1 form shouldnot have 2 submit buttons. you are confusing the HTML ?? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 10, 2009 Share Posted August 10, 2009 Well, what you should do is this. If your PHP is within the same page.. <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Or.. <form name="form" method="post" action="process.php"> This makes it so the FORM's Submit button actually sends a POST to.. process.php or $_POST['form']; variable in your PHP code.. Quote Link to comment Share on other sites More sharing options...
Gayner Posted August 10, 2009 Author Share Posted August 10, 2009 Why javascript should put here what will it do? this is php lol Quote Link to comment Share on other sites More sharing options...
Gayner Posted August 10, 2009 Author Share Posted August 10, 2009 Haha I fixed it.. You guys are all wrong? lol it's working just fine for me. if ( $_POST['remove'] ) { $DB->query("UPDATE ibf_members SET monkavatar='' WHERE id='{$ibforums->member['id']}'"); $print->redirect_screen( 'Thanks avatar is Removed!', "act=UserCP&CODE=Avatar" ); } Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 10, 2009 Share Posted August 10, 2009 You should add a name to the other submit button... Quote Link to comment Share on other sites More sharing options...
Gayner Posted August 10, 2009 Author Share Posted August 10, 2009 You should add a name to the other submit button... I Did.. <input type="submit" name="remove" value="Remove Avatar"> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 10, 2009 Share Posted August 10, 2009 <input type="submit" name="submit" value="Update Avatar"> Quote Link to comment 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.