Jump to content

The Option name cannot be retrieve after calling $POST


shebbycs

Recommended Posts

<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>");

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>";

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.

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 :)

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?

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 :(

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

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.