Page 1 of 1

Help needed!

Posted: Wed Jun 03, 2009 12:27 am
by helpless & lost kid
Hi, Im currently doing a school project. It seem that everytime i try to launch this .php file, it will open up another tab in Dreamweaver instead of opening it in the IE. Think its the coding error. Need help!

Code: Select all

 
<?php
    session_start(); // load session
    
    $_SESSION['errorMessage'] = "";
    
    if($_POST['IOS'] != "")
    {
        if($_POST['IOS'] == "5r5")
        {
            $_SESSION['manual'] = "5r5|05|210";
            header('Location: recover IOS/5r5_IOSrecovery.php');
            exit();
        }
        if($_POST['IOS'] == "5r6")
        {
            $_SESSION['manual'] = "5r6|06|210";
            header('Location: recover IOS/5r6_IOSrecovery.php'); 
            exit();
        }
    }
    
    if($_POST['device'] != "")
    {
        if($_POST['device'] == "5r2") // device name
        {
            $_SESSION['manual'] = "5r2|02|210"; // router name, line number, ip address
            if ($_SESSION['user'] = 1)
            {
                $_SESSION['5r2_UserID'] = $_SESSION['UserID'];
            }
            header('Location: 5r2 Switch/General.php'); // page load
            exit();
        }
        if($_POST['device'] == "5r3")
        {
            $_SESSION['manual'] = "5r3|03|210";
            if ($_SESSION['user'] = 1)
            {
                $_SESSION['5r3_UserID'] = $_SESSION['UserID'];
            }
            header('Location: 5r3 Router/General.php');
            exit();
        }
            
        if($_POST['device'] == "5r4")
        {
            $_SESSION['manual'] = "5r4|04|210";
            if ($_SESSION['user'] = 1)
            {
                $_SESSION['5r4_UserID'] = $_SESSION['UserID'];
            }
            header('Location: 5r4 Switch/General.php');
            exit();
        }
        if($_POST['device'] == "5r5")
        {
            $_SESSION['manual'] = "5r5|05|210";
            if ($_SESSION['user'] = 1)
            {
                $_SESSION['5r5_UserID'] = $_SESSION['UserID'];
            }
            header('Location: 5r5 Router/General.php');
            exit();
        }
        if($_POST['device'] == "5r6")
        {
            $_SESSION['manual'] = "5r6|06|210";
            if ($_SESSION['user'] = 1)
            {
                $_SESSION['5r6_UserID'] = $_SESSION['UserID'];
            }
            header('Location: 5r6 Router/General.php');
            exit();
        }
        if($_POST['device'] == "Jup1")
        {
            $_SESSION['manual'] = "JuniperRouter|49|210"; //Please connect your router to the correct port
            header('Location: Other Routers/JuniperRouter.php');
            exit();
        }
 
        if($_POST['device'] == "Sys1")
        {
            $_SESSION['manual'] = "LinkSys|50|210"; //Please connect your router to the correct port
            header('Location: Other Routers/LinkSys.php');
            exit();
        }
 
        if($_POST['device'] == "Net1")
        {
            $_SESSION['manual'] = "NetGear|51|210"; //Please connect your router to the correct port
            header('Location: Other Routers/NetGear.php');
            exit();
        }
    }
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Unified Platform Network Deployment System</title>
<link href="stylesheet/cssStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
</script>
<style type="text/css">
<!--
.style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif
}
.style2 {
    font-family: "Times New Roman", Times, serif;
    font-weight: bold;
    font-size: 12pt;
}
.style3 {color: #FFFFFF}
.style4 {color: #000000}
-->
</style>
</head>
 
<body>
<center>
<img src="assets/images/unified.png" border="0" />
 
<table width="650px" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
    <td class="header" align="center"><h1 class="style3"><span class="style4">Welcome</span> <span class="style4"><?php echo $_SESSION['UserID'] ?></span></h1></td>
</tr><br><center><b><font size="2">172.16.223.210</font></b></center>
<tr>
  <td><?php if($_SESSION['Administrator'] == 'yes')
    { 
        echo '<a href="create_users.php"><font size=2 color="blue"><p>Create New User</font></p></a>';
    }
    ?>
    </td><td>
    <div align="right"><a href="Login.php"><font size=2 color="blue">Logout</font><br></a>    </div></td>
</tr>
<tr>
    <td class="instruct">
      <p class="style1 style4"><font size="2">
      This system is capable of configuring, testing and reporting performances of multi-vendor network devices. The invention          offers a quick and convenient system that assists network designers and professionals to plan and deploy a network system without the need to remember all the detailed configuration commands, syntaxes and procedures specific to a particular vendor.</font><br>
      <br>
      </p>    </td>
</tr>
<tr>
    <td class="instruct"><span class="style2"><span class="style4">Select a vendor from dropdown menu to view a list of network devices available for configuration.</span></span> </td>
</tr>
<tr><td height="20px"></td>
</tr>
<tr>
    <td align="center">
 
    <!-------START selection of vendor & network devices START------->
        <form name="menuList" method="post" action="<?php echo $PHP_SELF; ?>">
              <p><strong>List of Devices&nbsp;&nbsp;:</strong><br />
               <?php
                    echo "<SELECT NAME=device >";
                    echo "<OPTION VALUE=0>-- Choose One --</OPTION>";
                    echo "<OPTION VALUE=5r2>5r2 Switch</OPTION>";
                    echo "<OPTION VALUE=5r3>5r3 Router</OPTION>";
                    echo "<OPTION VALUE=5r4>5r4 Switch</OPTION>";
                    echo "<OPTION VALUE=5r5>5r5 Router</OPTION>";
                    echo "<OPTION VALUE=5r6>5r6 Router</OPTION>";
                    echo "<OPTION VALUE=0>-- Other Routers --</OPTION>";
                    echo "<OPTION VALUE=Jup1> Juniper Router</OPTION>"; 
                    echo "<OPTION VALUE=Sys1> LinkSys Router</OPTION>";
                    echo "<OPTION VALUE=Net1> Net Gear Router</OPTION>";
                    echo "</SELECT>";
                    $con1 = FALSE;
                ?>
              </p>
              <p></p>
 
        <tr>
            <td align="center">
            <input type="submit" name="submit" id="submit" value="Start Configuration" />                                       </td>
        </tr>
        </form>
    <tr><td align="center">
    <form action="testconfig/testconfig.php" method="post" name="form2" id="form2"                                                  target = _new>
      <br>
        <input name="test_submit" type="submit" id="test_submit" value="Check Configurations"  >
     </form>
     </td></tr>
     <form action="<?php echo $PHP_SELF; ?>" method="post" name="form3">
         <tr>
           <td align="center">
<?php
    if($_SESSION['Administrator'] == 'yes')
    {
        echo "<br><b>Recover network device IOS</b></br>";
        echo "<select name=IOS>";
        echo "<option value=0>Please select a network device</option>";
        echo "<option value=5r5>5r5 Router</option>";
        echo "<option value=5r6>5r6 Router</option>";
        echo "</select>";
        echo "<input type=submit value=Recover IOS>";
    }
?>          </td>
         </tr>
     </form>
    <form action="Clearline.php" method="post" name="form" id="form">
    <tr><td align="center">
<?php
    if($_SESSION['Administrator'] == 'yes')
    {
        echo '<br><input name="test_submit" type="submit" id="test_submit" value="Clear All Lines">';   
    }
?>
</td></tr>
</form>
     </form>
  <!-------END selection of vendor & network devices END------->    
 

Re: Help needed!

Posted: Wed Jun 03, 2009 1:14 am
by califdon
When you say that you "launch" a .php script, are you aware that .php scripts are not programs that can be run on a computer, they are scripts that must be interpreted by a web server, such as Apache or IIS. You cannot just "run" them or view them in a browser, without having a web server installed.

Re: Help needed!

Posted: Wed Jun 03, 2009 3:35 am
by prometheuzz
califdon wrote:When you say that you "launch" a .php script, are you aware that .php scripts are not programs that can be run on a computer, they are scripts that must be interpreted by a web server, such as Apache or IIS. You cannot just "run" them or view them in a browser, without having a web server installed.
You're right that you can't open PHP files directly in a web browser (and expect them to be interpreted), but you can run PHP scripts as if they are applications using PHP-CLI: http://www.php-cli.com/

Re: Help needed!

Posted: Wed Jun 03, 2009 3:52 am
by helpless & lost kid
I've already install Apache already. but its seem that only some of the files in the folder cant be preview in IE. while the rest all okay. Apache is already running and MySql is running too. any idea what went wrong? Do I have to reinstall anything.

Re: Help needed!

Posted: Wed Jun 03, 2009 11:56 am
by califdon
helpless & lost kid wrote:I've already install Apache already. but its seem that only some of the files in the folder cant be preview in IE. while the rest all okay. Apache is already running and MySql is running too. any idea what went wrong? Do I have to reinstall anything.
I can't tell what you are doing, of course, but usually when someone makes this kind of complaint, it turns out that they are trying to open the .php script as a file, which won't work, because it bypasses the web server. Make sure that you request the file from the server, by entering localhost/xxxxxxx.php, and don't use Ctrl+O or go to the File menu and Open...

I doubt that you need to reinstall anything. Try this: create a simple text file:

Code: Select all

<?php
phpinfo();
?>
and save it as phpinfo.php. Then in your browser, enter localhost/phpinfo.php. If it runs, your Apache and PHP installation is fine.

Re: Help needed!

Posted: Wed Jun 03, 2009 7:55 pm
by helpless & lost kid
Thanks all, the problem has been solved.