Solved

Using var. from URL

Posted on 2004-04-25
3
170 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
3 Comments
 
LVL 6

Accepted Solution

by:
jkna_gunn earned 125 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now