Ankündigung

Einklappen
Keine Ankündigung bisher.

<form> aus Quelltext holen

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • <form> aus Quelltext holen

    hallo ich möchte die dormulare in Arrays schreiben ,aber bräuchte noch hilfe bei der Optimierung
    also hättet ihr es einfacher gemacht wenn ja ,was und wie?


    PHP-Code:
    <?PHP
    $fp
    =fopen("form.html","r");
    $read=fread($fp,216144);
    $form_s="<form";

    $form_e="</form>";
    $textarea_s="<textarea";
    $textarea_e="</textarea>";
    $count_textarea=substr_count($read,$textarea_s);
    $count_form=substr_count($read,$form_s);
    $count_textarea_e=substr_count($read,$textarea_e);
    $count_form_e=substr_count($read,$form_e);

    if(!
    $count_form)
    {
    $form_s="<FORM";
    }else (
    $form_s="<Form");

    if(!
    $count_textarea)
    {
    $textarea_s="<TEXTAREA";
    }else (
    $textarea_s="<Textarea");

    if(!
    $count_form_e)
    {
    $form_e="</FORM";
    }else (
    $form_e="</Form");

    if(!
    $count_textarea_e)
    {
    $textarea_e="</TEXTAREA";}
    else (
    $textarea_e="</Textarea");
    $count_textarea=substr_count($read,$textarea_s);
    $count_form=substr_count($read,$form_s);
    $count_textarea_e=substr_count($read,$textarea_e);
    $count_form_e=substr_count($read,$form_e);

    if (
    eregi($textarea_s,$read ))

    {

    $read1=stristr($read,$form_s);

    // <form>s säubern -(spiegeln :/ ) egal klappt ja.
    $form_eu=strrev($form_e);
    $readu=strrev($read);
    $readu=stristr($readu,$form_eu);
    $read=strrev($readu);
    $read=stristr($read,$form_s);
    //<form>s ersetzten mit |...
    $readr=str_replace($form_e,"</form>|",$read );
    //dann wieder trennen anhand von |
    $readr=explode("|",$readr);
    // zuordnen- :-/ ..mühsam
    switch($count_form)
    {
        case 
    "1":$form[1]=stristr($readr[0],$form_s);
            
            break;
        case 
    "2":$form1=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
            
            break;
        case 
    "3"$form[1]=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
                        
    $form[3]=stristr($readr[2],$form_s);
                            
            break;
        case 
    "4"$form[1]=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
                        
    $form[3]=stristr($readr[2],$form_s);
                            
    $form[4]=stristr($readr[3],$form_s);
            
            break;
        case 
    "5"$form[1]=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
                        
    $form[3]=stristr($readr[2],$form_s);
                            
    $form[4]=stristr($readr[3],$form_s);
                                
    $form[5]=stristr($readr[4],$form_s);
            
            break;
        case 
    "6":$form[1]=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
                        
    $form[3]=stristr($readr[2],$form_s);
                            
    $form[4]=stristr($readr[3],$form_s);
                                
    $form[5]=stristr($readr[4],$form_s);
                                    
    $form[6]=stristr($readr[5],$form_s);
            
            break;
        case 
    "7":$form[1]=stristr($readr[0],$form_s);
                    
    $form[2]=stristr($readr[1],$form_s);
                        
    $form[3]=stristr($readr[2],$form_s);
                            
    $form[4]=stristr($readr[3],$form_s);
                                
    $form[5]=stristr($readr[4],$form_s);
                                    
    $form[6]=stristr($readr[5],$form_s);
                                     
    $form[7]=stristr($readr[6],$form_s);    break;
        default:    
            ;
    }
    /* falsch....
    if (!eregi($textarea_s,$form[1]))
    {unset($form[1]);
    }
    else {
    $form[1]=$form[1];
    }
    if (!eregi($textarea_s,$form[2]))
    {unset($form[2]);
    }
    else {
    $form[2]=$form[2];
    }
    if (!eregi($textarea_s,$form[3]))
    {unset($form[3]);
    }
    else {
    $form[3]=$form[3];
    }
    if (!eregi($textarea_s,$form[4]))
    {unset($form[4]);
    }
    else {
    $form[4]=$form[4];
    }
    if (!eregi($textarea_s,$form[5]))
    {unset($form[5]);}
    else {
    $form[5]=$form[5];
    }
    if (!eregi($textarea_s,$form[6]))
    {unset($form[6]);}
    else {
    $form[6]=$form[6];
    }
    falsch ende
    */

    sort($form);
    $zahl=count($form);
    $xy="|";
    $textarea_sx="<textarea>";
    $textarea_sx .= "".$xy;
    $forma_[0]=str_replace($textarea_s,$textarea_sx,$form[0] );
    if (isset(
    $form[1]))
    {
    $forma_[1]=str_replace($textarea_s,$textarea_sx,$form[1] );}
    if (isset(
    $form[2]))
    {
    $forma_[2]=str_replace($textarea_s,$textarea_sx,$form[2] );
    }
    if (isset(
    $form[3]))
     {
    $forma_[3]=str_replace($textarea_s,$textarea_sx,$form[3] );  
    }
    if (isset(
    $form[4])) 
    {
    $forma_[4]=str_replace($textarea_s,$textarea_sx,$form[4] );  
    }
    if (isset(
    $form[5]))
     {
    $forma_[5]=str_replace($textarea_s,$textarea_sx,$form[5] );  
    }
    if (isset(
    $form[6])) 
    {
    $forma_[6]=str_replace($textarea_s,$textarea_sx,$form[6] );  
    }
    $formb1=explode("|",$forma_[0]);
    if (isset(
    $forma_[2])) {
    $formb2=explode("|",$forma_[1]);}
    if (isset(
    $forma_[2])) {
    $formb3=explode("|",$forma_[2]);}
    if (isset(
    $forma_[3])) {
    $formb4=explode("|",$forma_[3]);}
    if (isset(
    $forma_[4])) {
    $formb5=explode("|",$forma_[4]);}
    if (isset(
    $forma_[5])) {
    $formb6=explode("|",$forma_[5]);}
    if (isset(
    $forma_[6])) {
    $formb7=explode("|",$forma_[6]);}


    $formb1[1]=strstr($formb1[1],$textarea_e);
    $form1=implode("|",$formb1);

    if (isset(
    $formb2[1])){
    $formb2[1]=strstr($formb2[1],$textarea_e);
    $form2=implode("|",$formb2);}
    if (isset(
    $formb3[1])){
    $formb3[1]=strstr($formb3[1],$textarea_e);
    $form3=implode("|",$formb3);}
    if (isset(
    $formb4[1])){
    $formb4[1]=strstr($formb4[1],$textarea_e);
    $form4=implode("|",$formb4);}

    $db=mysql_connect("localhost","root","");
    mysql_select_db("save",$db);
    $sql="select * FROM mission";
    $result=mysql_query($sql);
     
    // while
    if (isset($form1))
     {
        
    }if (isset(
    $form2))
     {
        
    }if (isset(
    $form3)) 
    {
        
    }if (isset(
    $form4)) 
    {
        
    }if (isset(
    $form5)) 
    {
        
    }
    echo 
    $form1;
    }
    else echo(
    nee);

    ?>

  • #2
    keine optimierung sondern grundlagen"forschung":
    mysql_query() IMMER mit mysql_error() verbinden
    Code:
    mysql_query( $sql ) or die( mysql_error() );
    grüße ben.
    [b][url=http://www.benjamin-klaile.de]privater Blog[/url][/b]

    Kommentar

    Lädt...
    X