Jump to content

uwictech

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by uwictech

  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(); ?>
  15. Thanks bricktop that looks better I seem to be getting this error Warning: Missing argument 2 for PHPTelnet::DoCommand(), called in C:\xampp\htdocs\telnet.php on line 45 and defined in C:\xampp\htdocs\php-telnet\PHPTelnet.php on line 95 This is that part of the code in the file it's pointing at function DoCommand($c,&$r) { if ($this->fp) { fputs($this->fp,"$c\r"); $this->Sleep(); $this->GetResponse($r); $r=preg_replace("/^.*?\n(.*)\n[^\n]*$/","$1",$r);
  16. Hi Bricktop I need variable in the $telnet->DoCommand('config wlan security wpa1 pre-shared-key enable 1 ascii $string1'); I think I've solved it. I just used " " in stead of ' ' J
  17. Hi guy's, I've found a way to connect to an appliance and change password information using PHP and TELNET. I have a random password generator which puts the password into a variable, could I incorporate that into the telnet command? J <?php function randomPass1 ($cut) { global $string1; $string1 = md5(time()); $string1 = substr($string1 , 0 , $cut); return $string1; } echo randomPass1(; ?> <?php function randomPass2 ($cut) { global $string2; $string2 = md5(time()); $string2 = substr($string2 , 15 , $cut); return $string2; } echo randomPass2(; ?> <?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('192.168.##','admin','#'); if ($result == 0) { $telnet->DoCommand('config wlan disable 1'); // NOTE: $result may contain newlines $telnet->DoCommand('config wlan security wpa1 pre-shared-key enable 1 ascii $string1'); $telnet->DoCommand('config wlan enable 1'); // say Disconnect(0); to break the connection without explicitly logging out $telnet->Disconnect(); }
  18. Unfortuatly the place where I work will not allow me to install Linux servers! Is there no easier way of doing other than installing a Linux type of emulator and install SSH that way? J.
  19. So simple when you know how! Thanks once again! Jamie
  20. OK, thanks for you rinput once again guy's. Jamie
  21. Hi all, I have put together 2 separate bits of code. The 1st part generates a random password and the 2nd part is an email form. I would like to echo the password into the message box of the email form so that I can email users. I could easily do this if the password were a variable but to show the password I'm echoing the function. Jamie <?php function randomPass ($cut) { $string = md5(time()); $string = substr($string , 0 , $cut); return $string; } echo randomPass(; ?> <?php if ($_POST['submit']);{ $name = $_POST['name']; $message = $_POST['message']; } if ($name&&$message) { if (strlen($name)<=20&&strlen($message)<=300); { ini_set("SMTP", "e2k3vs01.internal.uwic.ac.uk"); $to = "jhancock@uwic.ac.uk"; $subject = "TEST"; $headers ="From: telephonedatabase@uwic.ac.uk"; $body = "Email From $name\n\n$message\n\n "; mail($to, $subject, $body, $headers); die(); } } ?> <html> <form action="email.php" method="POST"> Name: <input type ="test" name="name" maxlength="20"><br> Message: <br> <textarea name="message"></textarea><p> <input type="submit" name="submit" value="Send me this"> </form> </html>
  22. Hi all, I would like to set a condition in a txt box that says the number a user enters has to be in the following format ###-#-##-## Would I use PHP to do this or is it part of the HTML form? Jamie
×
×
  • 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.