php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2005

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 17.03.2005, 11:09  
Gast
 
Beiträge: n/a
Standard die code php und svg braucht man

dann in file addhotel.php
sind errors beim eingabe in Date Base fur neues Country und City, kann nicht die .jpeg und .svg files upload in bestimmtes phad machen?



PHP:

<?php
session_start();
if (!session_is_registered("valid_user")|| $valid_user!="admin")
{
echo "Only the administrator has permisions to visit this page!</br>";
exit();

}
include ("func.php");

ConectDb();

$flag=true;

if (!$hotel_name || !$hotel_addr || !$hotel_catagory || !$hotel_info || !$hotel_details || !$hotel_room)

{
echo "You didn't fill some field(s)!Please go back and fill all correct!";
$flag=0;
saveForm("hotelForm.php");
exit();

}

if (!(ereg("^[a-zA-Z0-9]+$",$hotel_name)))
{
echo "<tr><td>Notice:</td></tr>";
echo "<tr><td>The name of the hotel is maybe not correct!Please go back and try again!</td></tr></br>";
$flag=0;
saveForm("hotelForm.php");
exit();
}

$query="SELECT city.city_id FROM countries,city WHERE countries.country_name='$hotel_country' and city.city_name='$hotel_city' and city.c_id=countries.c_id;";
$res=mysql_query($query);
if (!$num_rows=@mysql_num_rows($res))
{

$query_country="SELECT countries.c_id FROM countries WHERE countries.country_name='$hotel_country';";
$res_country=mysql_query($query_country);
if (!$num_rows=@mysql_num_rows($res_country))
{
echo "<center>This country doesn't exist in the database!Please go back and enter it first!</center>";
saveForm("hotelForm.php?flag=NECountry");
exit();
/*$relative_url="addcountry.php?name=$hotel_country &kind=country";
header("Location: http://".$_SERVER['HTTP_HOST']
.dirname($_SERVER['PHP_SELF'])
."/".$relative_url);
exit();*/
}


else
{
$temparray=@mysql_fetch_array($res_country);
$c_id=$temparray["c_id"];
$query_city="SELECT city.city_id FROM city WHERE city.city_name='$hotel_city';";
$res_city=mysql_query($query_city);
if (!$num_rows=@mysql_num_rows($res_city))
{
echo "<center>This city doesn't exist in the database!Please go back and enter it first!</center>";
saveForm("hotelForm.php?flag=NECity&c_id=$c_id");
exit(); /*$relative_url="addcountry.php?name=$hotel_city&c_ id=$c_id&kind=city";
header("Location: http://".$_SERVER['HTTP_HOST']
.dirname($_SERVER['PHP_SELF'])
."/".$relative_url);


exit();*/
}
else
{
echo "<center>You have entered wrong city and country!Please go back and try again!</center></br>";
saveForm("hotelForm.php");
exit();
}
}
}

else
{
$temparray=@mysql_fetch_array($res);
$hotel_city_id=$temparray["city_id"];
$flag=1;
}


//PROVERKA NA VHODNITE DANNI OT hotelForm.php

if ((strlen($hotel_addr) < 3) || (strlen($hotel_addr) > 100))
{
echo "The addres of the hotel is maybe not correct!Please go back and try again!</br>";

$flag=0;
saveForm("hotelForm.php");
exit();
}
if (!(ereg("^[0-9]+$",$hotel_catagory)) || ($hotel_catagory > 5))
{
echo "<tr><td>The catagory of the hotel is not correct!Please go back and try again!</td></tr></br>";
$flag=0;
saveForm("hotelForm.php");
exit();
}
if (!empty($userfile))
{
if($userfile_size==0)
{
echo "Uploaded file is zero length";
$flag=0;
saveForm("hotelForm.php");
exit();
}
if(($userfile_type!="image/jpg") && ($userfile_type!="image/png") && ($userfile_type!="image/gif"))
{
echo "The type of the file is not correct!It must be with extension .jpg ,.png or .gif!Please go back and upload correct file!";
echo "$userfile_type";
$flag=0;
saveForm("hotelForm.php");
exit();
}
}
//echo "<form><input type='button' name='Back' value='Back' onclick='history.back();'></form>";
//KRAI NA PROVERKATA NA VHODNITE DANNI
if ($flag)
{
$hotel_name=trim($hotel_name);
$hotel_catagory=trim($hotel_catagory);
if (!empty($userfile))
{
$uploaddir = "\\home\\localhost\\www\\";
$uploadfile = $uploaddir.$userfile_name;
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "Could not move file into directory!";
saveForm("hotelForm.php");
exit();
}
}
//$data=addslashes(fread(fopen($hotel_view, "rb"), filesize($hotel_view)));
$query_ins="INSERT INTO hotels (city_id,name,addr,stars,info,hoteldetails,roomama nity,h_pic) VALUES ('$hotel_city_id','$hotel_name','$hotel_addr','$ho tel_catagory','$hotel_info','$hotel_details','$hot el_room','$userfile_name')";
$res_ins=mysql_query($query_ins);
if (!$res_ins)
{
echo "The operation failed! Please try again later!";
exit();

}
else
{
//PREDAVANE KYM SCRIPT ZA VYVEJDANE NA TIPOVE STAI
//$query_sel="SELECT h_id FROM hotels WHERE name='$hotel_name';";
//$res_sel=mysql_query($query_sel);
//$temparray=@mysql_fetch_array($res_sel);
//$hotel_id=$temparray["h_id"];
$hotel_id=mysql_insert_id();


$relative_url="addroom.php?hotel_id=$hotel_id";
header("Location: http://".$_SERVER['HTTP_HOST']
.dirname($_SERVER['PHP_SELF'])
."/".$relative_url);
exit();
//echo "The information for the hotel was entered successful";



}

}
echo "<html>";
echo "<body link='#4040FF' vlink='#463FA3' bgcolor='#eeeeee' >";
TableAdmin();

?>

</body>

</html>


also ich bekomme immer error:"The type of the file is not correct!It must be with extension .jpg ,.png or .gif!Please go back and upload correct file!
 
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 17.03.2005, 11:22  
Gast
 
Beiträge: n/a
Standard

sorry aber das tue ich mir nicht an.
1. Code-Tag!
2. relevanter Code!
3. Ich versteht kein Wort!
 
Alt 17.03.2005, 11:26  
Moderator
 
Benutzerbild von robo47
 
Registriert seit: 03.09.2004
Beiträge: 11.792
PHP-Kenntnisse:
Fortgeschritten
robo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz seinrobo47 kann auf vieles stolz sein
Standard

also langsam aber sicher wirds nervig @ mods schließt den thread mal und vieleicht mal überlegen den user zu kicken, weil das gesapamme überall wird langsam schlimm.

mfg
robo47
robo47 ist offline  
Alt 17.03.2005, 12:26  
Erfahrener Benutzer
 
Benutzerbild von lazydog
 
Registriert seit: 02.04.2008
Beiträge: 4.032
lazydog befindet sich auf einem aufstrebenden Ast
Standard

  • Erstens: Offensichtlich hast du das Error-Reporting ausgeschaltet, sonst hättest du verschiedene Fehlermeldungen, die dir weiterhelfen würden
    Zweitens lass die @ vor den Befehlen weg und verwende mysql_error()
    Drittens hast du register_globals auf on was ein Sicherheitsproblem ist (http://ch2.php.net/register_globals)
    Viertens: Eröffne nicht mit jeder Frage gleich einen neuen Thred
    Fünftens rücke deinen Code anständig ein und benutze, wie von TripleT schon gesagt, Code- oder PHP-Tags (dass sind die Buttons über dem Fenster). Ich habe das jetzt ausnahmsweise gemacht, damit du auch den Unterschied siehst
PHP-Code:
<?php
session_start
();
if (!
session_is_registered("valid_user")|| $valid_user!="admin")
{
    echo 
"Only the administrator has permisions to visit this page!</br>";
    exit();
}
include (
"func.php");

ConectDb();
$flag=true;
if (empty(
$hotel_name) || empty($hotel_addr) || empty($hotel_catagory)
   || empty(
$hotel_info) || empty($hotel_details) || empty($hotel_room))

{
    echo 
"You didn't fill some field(s)!Please go back and fill all correct!";
    
$flag 0;
    
saveForm("hotelForm.php");
    exit();
}

if (!(
ereg("^[a-zA-Z0-9]+$"$hotel_name)))
{
    echo 
"<tr><td>Notice:</td></tr>";
    echo 
"<tr><td>The name of the hotel is maybe not correct!
                  Please go back and try again!</td></tr></br>"
;
    
$flag 0;
    
saveForm("hotelForm.php");
    exit();
}

$query "SELECT city.city_id
          FROM countries,city
          WHERE countries.country_name = '$hotel_country'
          and city.city_name = '$hotel_city'
          and city.c_id = countries.c_id;"
;
$res=mysql_query($query) or die(mysql_error());
if (!
$num_rows mysql_num_rows($res))
{
    
$query_country "SELECT countries.c_id
                      FROM countries
                      WHERE countries.country_name = '$hotel_country';"
;
    
$res_country mysql_query($query_country) or die(mysql_error());
    if (!
$num_rows mysql_num_rows($res_country))
    {
        echo 
"<center>This country doesn't exist in the database!
              Please go back and enter it first!</center>"
;
        
saveForm("hotelForm.php?flag=NECountry");
        exit();
        
/*$relative_url = "addcountry.php?name=$hotel_country&kind=country";
        header("Location: http://".$_SERVER['HTTP_HOST']
                . dirname($_SERVER['PHP_SELF'])
                . "/" . $relative_url);
        exit();*/
    
}
    else
    {
        
$temparray mysql_fetch_array($res_country);
        
$c_id $temparray["c_id"];
        
$query_city "SELECT city.city_id
                       FROM city
                       WHERE city.city_name = '$hotel_city';"
;
        
$res_city mysql_query($query_city) or die(mysql_error());
        if (!
$num_rows mysql_num_rows($res_city))
        {
            echo 
"<center>This city doesn't exist in the database!
                  Please go back and enter it first!</center>"
;
            
saveForm("hotelForm.php?flag=NECity&c_id=$c_id");
            exit();
            
/*$relative_url="addcountry.php?name=$hotel_city&c_id=$c_id&kind=cit
y";
            header("Location: http://" . $_SERVER['HTTP_HOST']
                    . dirname($_SERVER['PHP_SELF'])
                    . "/" . $relative_url);
            exit();*/
        
}
        else
        {
            echo 
"<center>You have entered wrong city and country!
                   Please go back and try again!</center></br>"
;
            
saveForm("hotelForm.php");
            exit();
        }
    }
}
else
{
    
$temparray mysql_fetch_array($res);
    
$hotel_city_id $temparray["city_id"];
    
$flag 1;
}

//PROVERKA NA VHODNITE DANNI OT hotelForm.php

if ((strlen($hotel_addr) < 3) || (strlen($hotel_addr) > 100))
{
    echo 
"The addres of the hotel is maybe not correct!
          Please go back and try again!</br>"
;
    
$flag 0;
    
saveForm("hotelForm.php");
    exit();
}
if (!(
ereg("^[0-9]+$",$hotel_catagory)) || ($hotel_catagory 5))
{
    echo 
"<tr><td>The catagory of the hotel is not correct!
           Please go back and try again!</td></tr></br>"
;
    
$flag 0;
    
saveForm("hotelForm.php");
    exit();
}
if (!empty(
$userfile))
{
    if(
$userfile_size == 0)
    {
        echo 
"Uploaded file is zero length";
        
$flag 0;
        
saveForm("hotelForm.php");
        exit();
    }
    if((
$userfile_type != "image/jpg") && ($userfile_type != "image/png") && ($userfile_type != "image/gif"))
    {
        echo 
"The type of the file is not correct! or die(mysql_error()
              It must be with extension .jpg ,.png or .gif!
              Please go back and upload correct file!"
;
        echo 
"$userfile_type";
        
$flag 0;
        
saveForm("hotelForm.php");
        exit();
    }
}
//echo "<form><input type='button' name='Back' value='Back'
         
onclick='history.back();'></form>";
//KRAI NA PROVERKATA NA VHODNITE DANNI
if ($flag)
{
    $hotel_name = trim($hotel_name);
    $hotel_catagory = trim($hotel_catagory);
    if (!empty($userfile))
    {
        $uploaddir = "
homelocalhostwww";
        $uploadfile = $uploaddir.$userfile_name;
        if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
        {
            echo "
Could not move file into directory!";
            saveForm("
hotelForm.php");
            exit();
        }
    }
    //$data = addslashes(fread(fopen($hotel_view, "
rb"), filesize($hotel_view)));
    $query_ins = "
INSERT INTO hotels (city_id,name,addr,stars,info,
                                      
hoteldetails,roomamanity,h_pic)
                  
VALUES ('$hotel_city_id','$hotel_name','$hotel_addr',
                          
'$hotel_catagory','$hotel_info','$hotel_details',
                          
'$hotel_room','$userfile_name')";
    $res_ins=mysql_query($query_ins);
    if (!$res_ins)
    {
        echo "
The operation failedPlease try again later!";
        exit();
    }
    else
    {
        //PREDAVANE KYM SCRIPT ZA VYVEJDANE NA TIPOVE STAI
        //$query_sel = "
SELECT h_id FROM hotels WHERE name='$hotel_name';";
        //$res_sel = mysql_query($query_sel);
        //$temparray = mysql_fetch_array($res_sel);
        //$hotel_id = $temparray["
h_id"];
        $hotel_id = mysql_insert_id();
        $relative_url = "
addroom.php?hotel_id=$hotel_id";
        header("
Locationhttp://" . $_SERVER['HTTP_HOST']
                 
dirname($_SERVER['PHP_SELF'])
                 . 
"/" $relative_url);
        exit();
        
//echo "The information for the hotel was entered successful";
    
}
}
echo 
"<html>";
    if (!
$res_ins)
    {
        echo 
"The operation failed! Please try again later!";
        exit();
    }
    else
    {
        
//PREDAVANE KYM SCRIPT ZA VYVEJDANE NA TIPOVE STAI
        //$query_sel = "SELECT h_id FROM hotels WHERE name='$hotel_name';";
        //$res_sel = mysql_query($query_sel);
        //$temparray = mysql_fetch_array($res_sel);
        //$hotel_id = $temparray["h_id"];
        
$hotel_id mysql_insert_id();
        
$relative_url "addroom.php?hotel_id=$hotel_id";
        
header("Location: http://" $_SERVER['HTTP_HOST']
                 . 
dirname($_SERVER['PHP_SELF'])
                 . 
"/" $relative_url);
        exit();
        
//echo "The information for the hotel was entered successful";
    
}
}
echo 
"<html>";
    if (!
$res_ins)
    {
        echo 
"The operation failed! Please try again later!";
        exit();
    }
    else
    {
        
//PREDAVANE KYM SCRIPT ZA VYVEJDANE NA TIPOVE STAI
        //$query_sel = "SELECT h_id FROM hotels WHERE name='$hotel_name';";
        //$res_sel = mysql_query($query_sel);
        //$temparray = mysql_fetch_array($res_sel);
        //$hotel_id = $temparray["h_id"];
        
$hotel_id mysql_insert_id();
        
$relative_url "addroom.php?hotel_id=$hotel_id";
        
header("Location: http://" $_SERVER['HTTP_HOST']
                 . 
dirname($_SERVER['PHP_SELF'])
                 . 
"/" $relative_url);
        exit();
        
//echo "The information for the hotel was entered successful";
    
}
}
echo 
"<html>";
echo 
"<body link='#4040FF' vlink='#463FA3' bgcolor='#eeeeee' >";
TableAdmin();
?>
</body>
</html>
?>
auch wenn ich es nicht als sinnvoll erachte, das Forum mit so elend langen Scripts vollzupflastern.
Und sechstens und letztens: Du schreibst zwar die Fehlermeldung (die du progammiert hast) hin, aber nicht den Wert von echo "$userfile_type"; (bzw. $_FILES['userfile']['type] bei register_globals = off). Der wäre aber eigentlich relevant
__________________
Gruss
L
lazydog ist offline  
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Probleme mit PHP Code HappyDieMuschel PHP Tipps 2008 7 28.05.2008 06:34
Design und Code Trennen TeazY PHP Tipps 2008 29 21.05.2008 12:08
Nur bestimmten Html Code zulassen? litterauspirna PHP Tipps 2008 5 29.04.2008 12:30
Datei einfügen aus Ausgabepuffer, damit PHP Code funktionier NetLook PHP Tipps 2006 17 25.10.2006 15:09
FiFo macht Probs beim Css Code Matthiasnet HTML, Usability und Barrierefreiheit 10 18.08.2006 13:14
bb code in htm code wandeln janni PHP Tipps 2007 2 04.11.2005 22:36
[Erledigt] JS Code in PHP Code?? HTML, Usability und Barrierefreiheit 12 08.08.2005 15:45
[Erledigt] Lesbarkeit von Code Off-Topic Diskussionen 6 14.07.2005 14:48
code aus db mit eval replacen chief-thomson PHP Tipps 2005-2 4 08.07.2005 15:33
Fehler im Code, kann ihn nicht finden PHP Tipps 2005 9 16.05.2005 16:17
Bestätigungmail code? PHP Tipps 2005 7 16.05.2005 13:18
[Erledigt] BB Code entfernen PHP Tipps 2005 2 25.04.2005 15:20
Benutzereingaben von Formular prüfen (Sicherer Code?) PHP Tipps 2005 6 27.01.2005 10:16
[Erledigt] bb code innerhalb von bb code geht nicht PHP Tipps 2007 2 12.01.2005 17:29

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
tableadmin php zend

Alle Zeitangaben in WEZ +2. Es ist jetzt 10:19 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.