Jump to content

[SOLVED] Working with Tables....


bizerk

Recommended Posts

I have designed a table layout, in which I want users to be able to upload files, as long as they have supplied a correct login name and password. When they upload a file, It will display the File NAME, SIZE, and TYPE. If they do not supply the right login information, it will display "wrong credentials". The entire script works perfectly fine, but when I try to incorporate it within TABLES it does not... Here is the entire Page with tables:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Joe Upload</title>
<style type="text/css">
<!--
body {
background-image: url(images/background-repeat.png);
}
body,td,th {
color: #FFFFFF;
}
.style1 {font-size: 10px}
-->
</style></head>
<body>
<form name="form1" method="post" action="" enctype="multipart/form-data">
  <div align="left">
    <table width="527" border="1" align="center">
      <tr>a
        <td width="8" valign="top"> </td>
        <td width="503" valign="top" background="images/hardwired.gif"><p class="style1"><b><u>LOGIN INFORMATION:</u></b><br />
          Name:
          <input type="text" name="name" />
        <br />
        <br />
          Password:
          <input type="password" name="password" />
        </p></td>
      </tr>
      <tr>
        <td height="120" rowspan="2" valign="top"> </td>
        <td height="59" valign="top" background="images/left_nav.jpg"><b><u>Upload a File:</u></b><br />
          1.
          <input type="file" name="imagefile" />
    <br />
    <br />
          2.
  <input type="file" name="imagefile2" />
  <br />
  <br />
          3.
  <input type="file" name="imagefile3" />
  <br />
  <br />
          4.
  <input type="file" name="imagefile4" />
  <br />
  <br />
          5.
  <input type="file" name="imagefile5" />
  <br />
          <br />
          6.
  <input type="file" name="imagefile6" />
  <br />
          <br />
          7.
  <input type="file" name="imagefile7" />
  <br />
          <br />
          8.
  <input type="file" name="imagefile8" />
  <br />
          <br />
          9.
  <input type="file" name="imagefile9" />
  <br />
          <br />
          10.
  <input type="file" name="imagefile10" />
  <br />
  <br />
  <input type="submit" name="Submit" value="Submit" />
  <br />
  <br />
  <br />
  <?

$lol = rand(1,100);
$Submit= "Submit";
$browser = $REMOTE_ADDR;
$name = $_POST['name'];
$password = $_POST['password'];
function uploadFiles($key)
{
$lol = rand(1,100);
copy ($_FILES[$key]['tmp_name'], "files/$lol".$_FILES[$key]['name'])
or die ("Error Occured When Uploading Image File to Directory");
echo "<br><u><b>File: {$_FILES[$key]['name']} Status</u></b><br><br>
File Size: {$_FILES[$key]['size']}<br>
File Type: {$_FILES[$key]['type']}<br>
<br><br>
File {$_FILES[$key]['name']} was uploaded Succesfully.<br>";
}
if($_POST['Submit']) {
if($name =="joe" and $password =="sefanubz4f")
{
foreach ($_FILES as $key=>$file)
		{
		if (!empty($file['name']))
			{
			uploadFiles($key);
			}
}
		}else{
		echo "Wrong Credentials, Please try to Login Again";
		}
		}
?></td>
      </tr>
      <tr>
        <td height="59" valign="top" background="images/orangebar.jpg"> </td>
      </tr>
    </table>
    <p><br />
      <br />
      <br />
      <br />
    </p>
  </div>
</form>
</body>
</html>

 

So yeah, Should i try to create the tables by using echo? I have only developed one layout previousley with tables and do not remember having any problems like this...I want the two results( either the image name, size, type or the WRONG CREDENTIALS to show up in a new row:

 

<td height="59" valign="top" background="images/orangebar.jpg"> </td>

 

how should i do this though? When I try to upload a file nothing happens, It does not upload, state any error, or give me the ELSE statements.

Link to comment
https://forums.phpfreaks.com/topic/38823-solved-working-with-tables/
Share on other sites

It has nothing to do with tables. Your opening <form> tag is wrong. You say:

 

<form name="form1" method="post" action="" enctype="multipart/form-data">

 

You must specify the action or the submit button does nothing. Since I see you have the code in your page, you must change it to:

 

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">

 

Then it should submit. At the bottom of the page, put all of that php code inside the following if:

 

if($_POST)

 

and make sure to close it at the end. This will stop the code from running if there is no POST data.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.