Solved

Using var. from URL

Posted on 2004-04-25
3
186 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 125 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

740 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