shebbycs Posted November 14, 2011 Share Posted November 14, 2011 <A href='banip.php'>Ban IPS</a> | <A href='unbanip.php'>Unban IP</a> | <A href='editdelete.php'>Edit/Delete messages</a><br> <?php $db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password if(!$db) die("no db"); if(!mysql_select_db("cute",$db)) //database name die("No database selected."); if(isset($_POST['submit'])) { $ipselects=$_POST['ipselects']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$ipselects')</SCRIPT>"); $unban="Delete from ipbans where IP='$ipselects'"; mysql_query($unban) or die("Could not unban"); print "IP Unbanned."; } else { print "<form action='unbanip.php' method='post'>"; $getips="SELECT * from ipbans"; $getips2=mysql_query($getips) or die("Could not get IPS"); print "<select name='ipselects'>"; while($getips3=mysql_fetch_array($getips2)) { print "<option value='$getips3[ipid]'>$getips3[iP]</option>"; } print "</select><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } ?> this is my code for unbanip, when selected the option drop down list value for example ip1 when im retrieve back using $post and im try to output it is blank may i know where is wrong in that code? $ipselects=$_POST['ipselects']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$ipselects')</SCRIPT>"); Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/ Share on other sites More sharing options...
joel24 Posted November 14, 2011 Share Posted November 14, 2011 is it returning anything? you're script tag is incorrect also... play around with print_r($_POST); and post what that prints also change the script tag echo "<script type='text/javascript'>window.alert('$ipselects')</script>"; Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287929 Share on other sites More sharing options...
Psycho Posted November 14, 2011 Share Posted November 14, 2011 You are passing the value from the field "ipdi" print "<option value='$getips3[ipid]'>$getips3[iP]</option>"; But, then you are using that value to try and delete a record where the field 'IP' is equal to that value $unban="Delete from ipbans where IP='$ipselects'"; So, you would not get the results you want even if you didn't get a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287935 Share on other sites More sharing options...
shebbycs Posted November 14, 2011 Author Share Posted November 14, 2011 is it returning anything? you're script tag is incorrect also... play around with print_r($_POST); and post what that prints also change the script tag echo "<script type='text/javascript'>window.alert('$ipselects')</script>"; change or not change it still same it pop out message blank although im had choose ip address my problem is it cannot read the $POST Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287938 Share on other sites More sharing options...
shebbycs Posted November 14, 2011 Author Share Posted November 14, 2011 You are passing the value from the field "ipdi" print "<option value='$getips3[ipid]'>$getips3[iP]</option>"; But, then you are using that value to try and delete a record where the field 'IP' is equal to that value $unban="Delete from ipbans where IP='$ipselects'"; So, you would not get the results you want even if you didn't get a blank page. ooo i get it then how to modified the code? Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287941 Share on other sites More sharing options...
shebbycs Posted November 14, 2011 Author Share Posted November 14, 2011 but moto if im removed that <A href='banip.php'>Ban IPS</a> | <A href='unbanip.php'>Unban IP</a> | <A href='editdelete.php'>Edit/Delete messages</a><br> <?php $db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password if(!$db) die("no db"); if(!mysql_select_db("cute",$db)) //database name die("No database selected."); if(isset($_POST['submit'])) { $ipselect=$_POST['ipselects']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$ipselect')</SCRIPT>"); echo "IP Unbanned."; } else { echo "<form action='unbanip.php' method='post'>"; echo "<select name='ipselects'>"; $getips="SELECT * from ipbans"; $getips2=mysql_query($getips) or die("Could not get IPS"); while($getips3=mysql_fetch_array($getips2)) { echo "<option value='$getips3[ipid]'>$getips3[iP]</option>"; } echo "</select><br>"; echo "<input type='submit' name='submit' value='submit'></form>"; } ?> still it shown the blank message Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287943 Share on other sites More sharing options...
shebbycs Posted November 14, 2011 Author Share Posted November 14, 2011 im had found my problem the answer is <A href='banip.php'>Ban IPS</a> | <A href='unbanip.php'>Unban IP</a> | <A href='editdelete.php'>Edit/Delete messages</a><br> <?php $db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password if(!$db) die("no db"); if(!mysql_select_db("cute",$db)) //database name die("No database selected."); if(isset($_POST['submit'])) { $ipselect=$_POST['ipselects']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$ipselect')</SCRIPT>"); $unban="Delete from ipbans where IP='$ipselect'"; mysql_query($unban) or die("Could not unban"); echo "IP Unbanned."; } else { echo "<form action='unbanip.php' method='post'>"; echo "<select name='ipselects'>"; $getips="SELECT * from ipbans"; $getips2=mysql_query($getips) or die("Could not get IPS"); while($getips3=mysql_fetch_array($getips2)) { echo "<option>$getips3[iP]</option>"; } echo "</select><br>"; echo "<input type='submit' name='submit' value='submit'></form>"; } ?> the option don need option value that all haha Quote Link to comment https://forums.phpfreaks.com/topic/251099-the-option-name-cannot-be-retrieve-after-calling-post/#findComment-1287945 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.