[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using var. from URL

Posted on 2004-04-25
3
Medium Priority
?
204 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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.
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.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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…
Suggested Courses

656 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