?
Solved

Using var. from URL

Posted on 2004-04-25
3
Medium Priority
?
198 Views
Last Modified: 2013-11-18
The problem is that we see the variables in the URL, but it is empty in the body of the script:

URL: "http://localhost/inst_add_assig.php?sec=99&co=9990"

page: inst_add_assig.php

[code]
<?php
include 'include.inc';
session_start();

if (empty($assigTitle)){
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Add an Assignment</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#FFFFe8">

<div id="Layer1" style="position:absolute; left:0px; top:0px; width:508px; height:52px; z-index:1"><img src="logo/eSubmissionbannerBigLighter.jpg" width="783" height="69"></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php echo"
<form name=\"form1\" method=\"post\" action=\"inst_add_assig.php?co=".$co."&amp;sec=".$sec." enctype=\"multipart/form-data\">";?>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">

  <table width="75%" border="0" align="center">
    <tr>
      <td><strong>Enter file name:</strong></td>
      <td><input type="file" name="uploadedFile" class="textfield"></td>
    </tr>
          <tr>
      <td><strong>Enter assignment title:</strong></td>
      <td><input type="text" name="assigTitle" class="textfield"></td>
    </tr>
    <tr>
      <td height="26"><strong>Due date:</strong></td>
      <td> <select name="select" class="select">
        </select> <select name="select2" class="select">
        </select> <select name="select3" class="select">
        </select> </td>
    </tr>
    <tr>
      <td height="21"><strong>Files to be included:</strong></td>
      <td height="21"><input type="text" name="textfield3" class="textfield"></td>
    </tr>
    <tr>
      <td height="113" colspan="2"><div align="center">
          <p>
            <input type="submit" >
          </p>
        </div></td>
    </tr>
  </table>
</form>

<p>&nbsp;</p>
</body>
</html>



<?php
}
else if (!empty($assigTitle))
{

 
if($HTTP_POST_FILES['uploadedFile']['size'] <=0)
{
    print"<b>Not recieved.</b><br>";
}
else
{    
      $assig=$_POST['assigTitle'];
      //$sect= $sec;
        //$cour= $_POST['courseName'];
      $username = strtolower($_SESSION["loginUsername"]);
      $dir =  "instructor/" . $username . "/" . $assig . "/";
      if(!file_exists($dir))
      mkdir($dir,0700);
        
        echo "***".$sec."***".$co;
        
        /******************************/
        
        //$assig=$_REQUEST['assigTitle'];
        //$username = strtolower($_SESSION["loginUsername"]);
      $destination=  "instructor/" . $username . "/". $assig . "/".$HTTP_POST_FILES['uploadedFile']['name'];
      
      copy($HTTP_POST_FILES['uploadedFile']['tmp_name'],$destination);
      //$HTTP_POST_FILES['uploadedFile']['name']);
      echo "******". $destination;
}
}
?>

[/code]

When pressing the submit button, the page will alwayes consider the statement "if (empty($assigTitle))" true
and I get the following URL
[url]http://localhost/inst_add_assig.php?co=&sec=%20enctype=[/url]
0
Comment
Question by:COMPUTER_SC_STUDENT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
jkna_gunn earned 500 total points
ID: 10911322
instead of adding the variables in the action part of the form tag
create hidden inputs inside your form

<form method="POST" action="inst_add_assig.php">
.. rest of form stuff
<input type="hidden" name="co" value="<?=$co?>">
<input type="hidden" name="sec" value="<?=$sec?>">
</form>

also i cant see where $assigTitle is getting initialised???

should you not have something like

$assignTitle = $_POST["assigTitle"];

before the if statment
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question