ugrás a tartalomhoz

HTML űrlap + a fájlfeltöltés problémái

a.d.a.m · 2006. Ápr. 29. (Szo), 11.13
Sziasztok!

Valamikor rég készült egy html űrlap, mivel azonban alkotója nem tulzottan értette a php, így megkért engem (vak vezet világtalant alapon), hogy ugyan készítsek már egy olyan php kódot ami feltölti az űrlapon keresztül a képet, ráadásul az űrlap adtait is elmenti egy fájlba. Ez megtörtént. Egy ideig nem is volt semmilyen gond, azonban az idő múlásával szaporodni kezdtek a jelen: hol a kép nem mentár, hol a szöveg fele hiányzott. Ezért többszörösen is átdolgozásra került az űrlap, míg végül elérte jelenlegi állapotát, ami mint egy kevéssé sem baráti e-mailból kiderült ismét nem tökéletes. Minthogy én nem vagyok túl nagy ÁSZ a PHP terén a segítségeteket szeretném kérni e probléma megoldásában.
Az oldal a www.orszagoslovasar.hu címen található, ezen belül a hirdetés feladás - eladó ló menüpont alatt.

Az oldal kódja a következő:
<?php
session_start();
if ( $_POST['kuldes'] == "feltolt" )
{
unset($_SESSION['return']);
if (isset($_FILES["kep"]["tmp_name"]) == true)
	{
	if ($_FILES["kep"]["size"]>=3000001)
		{
		$_SESSION['return'] = "false";
		echo "<script>window.alert('A kép feltöltése sikertelen! A feltöltött kép mérete nem megfelelő!');</script>";
		}
	else
		{
		move_uploaded_file($_FILES["kep"]["tmp_name"], "hirdetesek/".$_FILES["kep"]["name"]);
		$_SESSION['return'] = $_FILES["kep"]["name"];
		echo "<script>window.alert('A kép feltöltése sikeresen befejeződött!');</script>";
		}
	}
else
	{
	$_SESSION['return'] = "false";
	echo "<script>window.alert('A kép feltöltése sikertelen');</script>";
	}

$keys = array_keys($_POST);
$count = count($_POST);
for ( $array_index=0; $array_index<=($count-1); $array_index++ )
	{
		if ($keys[$array_index]!="MAX_FILE_SIZE" or $keys[$array_index]!="s")
			{$_SESSION[$keys[$array_index]] = $_POST[$keys[$array_index]];}
		else
			{}
	}

echo "<script>window.location.replace('felad-elado-felsz.php?s=".$_POST['s'].$link."');</script>";
}
?>
<html>

<head>
<title>Hirdet&eacute;s felad&aacute;s: elad&oacute; felszerel&eacute;s</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
<meta name="generator" content="Microsoft FrontPage 5.0">
<meta name="description" content="Lovat, felszerelést eladna, vagy venne? Adja fel hirdetését nálunk!">
<meta name="keywords" content="Lovas, lóvásár, eladó ló, apróhirdetés, lovassport ">
</head>

<script>
function feltolt()
	{
	document.adatok.kuldes.value="feltolt";
	document.adatok.submit();
	}
function elkuld()
	{
	document.adatok.kuldes.value="elkuld";
	return formCheck(document.adatok);
	}
function formCheck(formobj){
	var fieldRequired = Array("megr_nev", "megr_cim", "penz", "fajta", "neme", "alkalmas", "elerhetoseg");
	var fieldDescription = Array("Megrendelő neve", "Megrendelő címe", "Pénzfeladás módja", "Fajta", "Neme", "Mire vaLÓ", "Elérhetőség");
	var alertMsg = "Kérem töltse ki az alábbi mező(ke)t:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		formobj.action = "hirdetes.php";
		formobj.submit();
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
</script>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" background="images/hatter.jpg">
<form name="adatok" method="post" enctype="multipart/form-data">
        
    <p style="line-height:120%; margin-top:15pt; margin-bottom:0%;" align="center"><img src="images/fej-b1.gif" width="100%" border="0"></p>
    <p align="center" style="line-height:90%;"><font size="5"><b><i>APR&Oacute;HIRDET&Eacute;S FELAD&Aacute;S:&nbsp;&nbsp;&nbsp;&nbsp;ELAD&Oacute; FELSZEREL&Eacute;S</i></b></font></p>
    <p align="justify" style="line-height:120%; margin-top:0; margin-bottom:0;">A hirdet&eacute;s sz&ouml;veg&eacute;nek elk&uuml;ld&eacute;s&eacute;t&nbsp;k&ouml;vetően adja fel a hirdet&eacute;s &aacute;r&aacute;t&nbsp;(<font color="red"><b>1000 Ft / hirdet&eacute;s</b></font>, k&eacute;t h&oacute;napra) belf&ouml;ldi posta utalv&aacute;nyon (r&oacute;zsasz&iacute;n csekken) - ennek postai k&ouml;lts&eacute;ge jelenleg 5000 Ft-os &ouml;sszeg felad&aacute;s&aacute;ig 245 Ft - az al&aacute;bbi c&iacute;mre: <b>D&oacute;zsa Tam&aacute;s K&aacute;roly - 6401 Kiskunhalas, Pf. 311</b>, vagy banki &aacute;tutal&aacute;ssal: &nbsp;<b>OTP Bank Rt. Kiskunhalasi Fi&oacute;k 11773322-00527598</b> sz&aacute;m&uacute; sz&aacute;ml&aacute;ra. A p&eacute;nz meg&eacute;rkez&eacute;s&eacute;t k&ouml;vetően a hirdet&eacute;s megjelenik a honlapon, majd a megadott c&iacute;mre eljuttatjuk sz&aacute;ml&aacute;nkat.</p>
    <hr align="center" color="#FF9830" style="border-width:2; border-style:solid;">    
    <p align="center" style="line-height:90%;"><font color="red"><b><i>K&eacute;rj&uuml;k a kereszttel jel&ouml;lt rovatokat minden esetben t&ouml;lts&eacute;k ki! K&ouml;sz&ouml;nj&uuml;k!</i></b></font></p>
    <table width="664" align="center" bordercolordark="#707070" bordercolorlight="silver" class="namo-table" cellspacing="0" style="border-collapse:collapse;">
        <tr>
            <th width="660" class="namo-th" bgcolor="#FF9830" colspan="2" style="border-width:1; border-color:black; border-style:solid;">                            

                <p align="left" style="margin-left:2pt;">Sz&aacute;ml&aacute;z&aacute;shoz sz&uuml;ks&eacute;ges adatok:</p>
            </th>
        </tr>
        <tr>
            <th width="142" class="namo-th" bgcolor="#CCCCCC" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:2pt;">Megrendelő neve <font color="red"><b>#</b></font></p>
            </th>
            <td width="515" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:1mm;"><input type="hidden" name="s" value="<?php echo session_id(); ?>"><input type="hidden" name="kuldes"><input type="hidden" name="hirdetes" value="elado-felszereles";"><input type="text" name="megr_nev" size="70" style="font-family:'Times New Roman';" value="<?php if(isset($_GET['s'])==true) { echo $_SESSION['megr_nev']; } ?>"></p>
            </td>
        </tr>
        <tr>
            <th width="142" class="namo-th" bgcolor="#CCCCCC" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:2pt;">C&iacute;me <font color="red"><b>#</b></font></p>
            </th>
            <td width="515" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:1mm;"><input type="text" name="megr_cim" size="70" style="font-family:'Times New Roman';" value="<?php if(isset($_GET['s'])==true) { echo $_SESSION['megr_cim']; } ?>"></p>
            </td>
        </tr>
        <tr>
            <th width="142" bgcolor="#CCCCCC" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">
                <p style="margin-left:2pt;" align="left">P&eacute;nzfelad&aacute;s m&oacute;dja <font color="red">
                #</font></p>
            </th>
            <td width="515" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left"><input type="radio" name="penz" value="bank"<?php if(isset($_GET['s'])==true) { if ($_SESSION['penz'] == "bank") {echo " checked";} } ?>><span style="font-weight: 400">bank</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="penz" value="posta"<?php if(isset($_GET['s'])==true) { if ($_SESSION['penz'] == "posta") {echo " checked";} } ?>><span style="font-weight: 400">posta</span></p>
            </td>
        </tr>
        <tr>
            <th width="660" colspan="2" bgcolor="#FF9830" style="border-width:1; border-color:black; border-style:solid;">                            

                <p align="left" class="namo-sublist"> 
                            Hirdet&eacute;sben megjelenő sz&ouml;veg:</th>
        </tr>
        <tr>
            <th width="142" class="namo-th" bgcolor="#CCCCCC" style="border-width:1; border-color:black; border-style:solid;">

                <p align="left" style="margin-left:2pt;">Megnevez&eacute;s <font color="red"><b>#</b></font></p>
            </th>
            <td width="515" style="border-width:1; border-color:black; border-style:solid;">

                <p style="margin-left:1mm;"><input type="text" name="megnev" size="70" style="font-family:'Times New Roman';" value="<?php if(isset($_GET['s'])==true) { echo $_SESSION['megnev']; } ?>"></td>
        </tr>
        <tr>
            <th width="142" bgcolor="#CCCCCC" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">

                <p style="margin-left:2pt;" align="left">Tudni val&oacute;</p>
            </th>
            <td width="515" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">

                <p style="line-height:120%; margin-top:0; margin-bottom:0; margin-left:1mm;"><i><font size="2">K&eacute;rj&uuml;k p&aacute;r sorban mutassa be a&nbsp;főbb jellemzőit!</font></i><textarea name="megj" rows="5" cols="80" style="font-family:'Times New Roman';"><?php if(isset($_GET['s'])==true) { echo $_SESSION['megj']; } ?></textarea></p>
            </td>
        </tr>
        <tr>
            <th width="142" class="namo-th" bgcolor="#CCCCCC" height="26" style="border-width:1; border-color:black; border-style:solid;">                            

                <p align="left" style="margin-left:2pt;">Ir&aacute;ny&aacute;r (Ft)</p>
            </th>
            <td width="515" class="namo-th" height="26" style="border-width:1; border-color:black; border-style:solid;">

                <p align="left" style="margin-left:1mm;"><input type=text size="10" maxlength="10" name="ár" onchange=onlyNumber() style="font-family:'Times New Roman';" value="<?php if(isset($_GET['s'])==true) { echo $_SESSION['ár']; } ?>"></td>
        </tr>
        <tr>
            <th width="142" class="namo-th" bgcolor="#CCCCCC" height="26" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:2pt;">El&eacute;rhetős&eacute;g <font color="red"><b>#</b></font></p>
            </th>
            <td width="515" class="namo-th" height="26" style="border-width:1; border-color:black; border-style:solid;">

                <p align="left" style="margin-left:1mm;"><input type="text" name="elerhet" size="70" style="font-family:'Times New Roman';" value="<?php if(isset($_GET['s'])==true) { echo $_SESSION['elerhet']; } ?>"></p>
            </td>
        </tr>
        <tr>
            <td width="660" height="24" align="right" colspan="3" class="namo-th" style="border-width:1; border-color:black; border-style:solid;">
		<div style="background-color:#CCCCCC"><font size="2"><center><input type="hidden" name="kepadat" value="<?php if($_GET['s']!="false"){echo $_SESSION['return'];}else{echo "";} ?>"><?php if(isset($_GET['s'])==true){if($_GET['s']!="false"){echo $_SESSION['return']." feltöltve.";}else{echo "";}} ?></center></font></div>
                <p align="center" style="margin-top:10pt; margin-bottom:10pt;"><font size="2"><input type="button" onClick="elkuld();" value="Elküldés"> </font></p>
            </td>
        </tr>
        <tr>
            <th width="165" class="namo-th" bgcolor="#CCCCCC" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="margin-left:2pt;">K&eacute;p</p>
            </th>
            <td width="492" class="namo-th" colspan="2" style="border-width:1; border-color:black; border-style:solid;">
                <p align="left" style="line-height:120%; margin-left:1mm;"><font size="2"><i>Hirdet&eacute;s&eacute;ben&nbsp;egy k&eacute;pet is elhelyezhet (max. 3 Mbyte), adja meg annak hely&eacute;t</i></font><i>:</i>
                <input type="hidden" name="MAX_FILE_SIZE" value="5000000"><input type="file" name="kep" size="35"><input type="button" onClick="feltolt();" value="Feltöltés"></p>
		</td>
        </tr>
    </table>
</form>
<p align="right"><a href="hird-felt.html"><img src="images/nyil-elozo.gif" width="96" height="38" border="0"></a><a href="index.html"><font color="white">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><img src="images/nyil-nyito.gif" width="96" height="38" border="0"></a></p>
</body>

</html>
Kérek mindenkit, hogy mondja el a véleményét, adjon tanácsot és ötletet.
Előre is köszönöm a segítségeteket!
a.d.a.m