Jump to content

uwictech

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

uwictech's Achievements

Member

Member (2/5)

0

Reputation

  1. Sorry, fixed it. Need to wrapp the email send around the submit button! J.
  2. Hi Marcus, The page is still running when I go to it without pressing the submit button, is it clear what I'm doing wrong? J. <?php //run site query require("confwifi.php") ; $ext_site = $_POST['site']; $extract = mysql_query ("SELECT * FROM site WHERE site='$ext_site'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; } ?> <?php //run site query require("confwifi.php") ; { $ext_ssid = $_POST['ssid_name']; $extract = mysql_query ("SELECT * FROM ssid WHERE ssid_name='$ext_ssid'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $ssid_id = $row['ssid_id']; $ssid_name = $row['ssid_name']; } $ssidpass = $_POST['ssidpass']; } ?> <div class="boxextqry"> <h3> SSID CHANGE </h3> <form name="form1" method="post" action="../index1.php?page=wifichange"> <select name="site"> <option value="0" selected>(please select:)</option> <option name="site">Llandaf</option> <option name="site">Cyncoed</option> <option name="site">Howard Gardens</option> <option name="site">Colchester Avenue</option> </select> <p></p> <select name="ssid_name"> <option value="0" selected>(please select:)</option> <option name="ssid_name">Guest</option> <option name="ssid_name">Conferences</option> </select> <p><input type="text" name="ssidpass"></P> <input name ="submit" type="submit" value="submit"> </form> </div> <?php require_once "php-telnet/PHPTelnet.php"; if ($_POST['submit']){ $telnet = new PHPTelnet(); // if the first argument to Connect is blank, // PHPTelnet will connect to the local host via 127.0.0.1 $result = $telnet->Connect($ip,'admin','*****'); if ($result == 0) { $telnet->DoCommand('config wlan disable '.$ssid_id.''); // NOTE: $result may contain newlines $telnet->DoCommand('config wlan security wpa1 pre-shared-key enable 1 ascii '.$ssidpass.''); $telnet->DoCommand('config wlan enable '.$ssid_id.''); // say Disconnect(0); to break the connection without explicitly logging out $telnet->Disconnect(); } } ?> <?php ini_set("SMTP", "e2k3vs01.internal.uwic.ac.uk"); $to = "jhancock@uwic.ac.uk"; $subject = "WiFi Password"; $headers ="From: WiFi@uwic.ac.uk"; $body = "The WiFi password for the $ssid_id on the $ip campus, has been manually reset to: $ssidpass"; mail($to, $subject, $body, $headers); die(); ?>
  3. Sorry, fixed that! The trouble is, every time I go to the site the code runs. How do I set it so that it will not run until the submit button is pressed? Jamie <?php //run site query require("confwifi.php") ; { $ext_site = $_POST['site']; $extract = mysql_query ("SELECT * FROM site WHERE site='$ext_site'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; } } ?> <?php //run site query require("confwifi.php") ; { $ext_ssid = $_POST['ssid_name']; $extract = mysql_query ("SELECT * FROM ssid WHERE ssid_name='$ext_ssid'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $ssid_id = $row['ssid_id']; $ssid_name = $row['ssid_name']; } $ssidpass = $_POST['ssidpass']; } ?> <form name="form1" method="POST" action="wifichange.php"><div> <select name="site"> <option value="0" selected>(please select:)</option> <option name="site">Llandaf</option> <option name="site">Cyncoed</option> <option name="site">Howard Gardens</option> <option name="site">Colchester Avenue</option> </select> <p></p> <select name="ssid_name"> <option value="0" selected>(please select:)</option> <option name="ssid_name">Guest</option> <option name="ssid_name">Conferences</option> </select> <p><input type="text" name="ssidpass"></div></P> <input type="submit" value="submit"> </form> <?php require_once "php-telnet/PHPTelnet.php"; $telnet = new PHPTelnet(); // if the first argument to Connect is blank, // PHPTelnet will connect to the local host via 127.0.0.1 $result = $telnet->Connect($ip,'admin','K1n94+'); if ($result == 0) { $telnet->DoCommand('config wlan disable '.$ssid_id.''); // NOTE: $result may contain newlines $telnet->DoCommand('config wlan security wpa1 pre-shared-key enable 1 ascii '.$ssidpass.''); $telnet->DoCommand('config wlan enable '.$ssid_id.''); // say Disconnect(0); to break the connection without explicitly logging out $telnet->Disconnect(); } ?> <?php ini_set("SMTP", "e2k3vs01.internal.uwic.ac.uk"); $to = "jhancock@uwic.ac.uk"; $subject = "WiFi Password"; $headers ="From: WiFi@uwic.ac.uk"; $body = "The WiFi password for the $ssid_id on the $ip campus, has been manually reset to: $ssidpass"; mail($to, $subject, $body, $headers); die(); ?>
  4. Thanks mate, I was writing it the wrong way around drrrrr! I have another problem however, I doesn't seem to be pulling the $ip variable in the telnet program I have. Whe I echo it on screen, it come up with the correct ip? <?php //run site query require("confwifi.php") ; { $ext_site = $_POST['site']; $extract = mysql_query ("SELECT * FROM site WHERE site='$ext_site'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; } } ?> <?php //run site query require("confwifi.php") ; { $ext_ssid = $_POST['ssid_name']; $extract = mysql_query ("SELECT * FROM ssid WHERE ssid_name='$ext_ssid'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $ssid_id = $row['ssid_id']; $ssid_name = $row['ssid_name']; } $ssidpass = $_POST['ssidpass']; } ?> <form name="form1" method="POST" action="wifichange.php"><div> <select name="site"> <option value="0" selected>(please select:)</option> <option name="site">Llandaf</option> <option name="site">Cyncoed</option> <option name="site">Howard Gardens</option> <option name="site">Colchester Avenue</option> </select> <select name="ssid_name"> <option value="0" selected>(please select:)</option> <option name="ssid_name">Guest</option> <option name="ssid_name">Conferences</option> </select> </form> <p><input type="text" name="ssidpass"></div></P> <div><input type="submit" value="submit"></div> </form> <?php echo "$ip"; ?><p></p> <?php echo "$ssidpass"; ?><p></p> <?php echo "$ssid_id"; ?><p></p> <?php require_once "php-telnet/PHPTelnet.php"; $telnet = new PHPTelnet(); // if the first argument to Connect is blank, // PHPTelnet will connect to the local host via 127.0.0.1 $result = $telnet->Connect('$ip','admin','******'); if ($result == 0) { $telnet->DoCommand('config wlan disable '.$ssid_id.''); // NOTE: $result may contain newlines $telnet->DoCommand('config wlan security wpa1 pre-shared-key enable 1 ascii '.$ssidpass.''); $telnet->DoCommand('config wlan enable '.$ssid_id.''); // say Disconnect(0); to break the connection without explicitly logging out $telnet->Disconnect(); } ?>
  5. Hi all, I'm sure this is very easy but I'm having another brain freeze! At the end of the code I have echoed 3 bits of info to screen $ip, $_POST['ssid'] and $ssid_id". I would like to put $_POST['ssid'] into a variable, is this possible? Jamie <?php //run site query require("confwifi.php") ; { $ext_site = $_POST['site']; $extract = mysql_query ("SELECT * FROM site WHERE site='$ext_site'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; } } ?> <?php //run site query require("confwifi.php") ; { $ext_ssid = $_POST['ssid_name']; $extract = mysql_query ("SELECT * FROM ssid WHERE ssid_name='$ext_ssid'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $ssid_id = $row['ssid_id']; $ssid_name = $row['ssid_name']; } } ?> <form name="form1" method="POST" action="wifichange.php"><div> <select name="site"> <option value="0" selected>(please select:)</option> <option name="site">Llandaf</option> <option name="site">Cyncoed</option> <option name="site">Howard Gardens</option> <option name="site">Colchester Avenue</option> </select> <select name="ssid_name"> <option value="0" selected>(please select:)</option> <option name="ssid_name">Guest</option> <option name="ssid_name">Conferences</option> </select> </form> <p><input type="text" name="ssid"></div></P> <div><input type="submit" value="submit"></div> </form> <?php echo "$ip"; ?><p></p> <?php echo $_POST['ssid'];; ?><p></p> <?php echo "$ssid_id"; ?><p></p> <?php
  6. bugga! I have just posted it onto the AJAX forum. And there is me thinking it must be easy! J.
  7. Hi all, This is the first time I have posted on this forum, I was recomended from the PHP forum To cut a long story short here is the link to my post on the php forum. Hope someone can help! http://www.phpfreaks.com/forums/index.php?topic=275440.new;topicseen#new Jamie
  8. no problem there mate! I think I owe you more than 1!! Can I ask one more question? Is it possible to store that ip address in a variable, so that I can use it in some code I about to write? J.
  9. Bricktop, you are indeed a genius!! I hope someday I can help you in some way. I can't tell you how much I appreciate your help! Jamie
  10. Hi Bricktop, there is most defiantly no need to apologise! It's kind of doing what I want. When I choose an option from the drop down it echo's that out rather than the ip address associated with it the database. Sorry to be a pain! Jamie
  11. Thanks taquitosensei. I don't think I explained myself properly. What I would like is to do is, store what the user selects from the dropdown boxes into a variable to use later. Is that possible? Sorry for the confusion. Jamie <?php require("confwifi.php"); $ip_form = $_POST['ip']; $extract = mysql_query ("SELECT * FROM site"); $numrows = mysql_num_rows ($extract); echo"Select CAMPUS: <select name='ip'>"; while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; echo"<option name='$ip'>$site</option> "; } echo "</select>"; ?> <?php echo "$variable"; ?>
  12. Hi all, I'm having a brain freeze, hope you can help. I have created a simple drop down box that populates from a MySQL database. When I choose one of the options from the drop down box, I would like to print on screen a value associated with it in the database. So when I choose a specific site, it will show the ip address. my code is below, hope you can help. Jamie <?php require("confwifi.php"); $extract = mysql_query ("SELECT * FROM site"); $numrows = mysql_num_rows ($extract); echo"Select CAMPUS: <select name='site'>"; while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $site = $row['site']; $ip = $row['ip']; echo"<option name='$ip'>$site</option> "; } echo "</select>"; ?> <?php echo $ip; ?>
  13. bricktop, I owe you a pint or 12! Jamie
  14. Hi All, I'm struggling with the syntax in the code below. As you can see, I can echo out when the passwords will be valid until on the screen, but, I would like to put this into the email body. When I try it tells me I have a syntax error. Can someone help please? Jamie <?php $tomorrow = mktime(0,0,0,date("m"),date("d")+5,date("Y")); echo "These Passwords are valid until the ".date("d/m/Y", $tomorrow); ini_set("SMTP", "e2k3vs01.internal.uwic.ac.uk"); $to = "jhancock@uwic.ac.uk"; $subject = "WiFi Password"; $headers ="From: WiFi@uwic.ac.uk"; $body = "The new WiFi password for the Conferences SSID is: $string1\n\nThe new WiFi password for the Guest SSID is: $string2\n\n$tomorrow "; mail($to, $subject, $body, $headers); die(); ?>
×
×
  • 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.