Support » Allgemeine Fragen » PHP Send Form Data to WordPress Database

  • christian2019e

    (@christian2019e)


    Hey i trying to send formdata from a selfmade form to my WordPress Database.

    I have the following code, but i got no data in the database table. What is wrong?

    I allready tried to add some echos and var_export to check the data but when i click on submit the site reload and i cant see echo or var_export. So its hard to solve the issue.

    My site give me no errors it does all fine but there arrive no data to my wordpress database.

     <?php
    /* Template Name: CustomPageT1 */
    $vorname = $POST['field_vorname'];
    $name = $_POST['field_name'];
    $email = $_POST['field_email'];
    $phone = $_POST['field_phone'];
    $region = $_POST['field_hilsorganisation'];
    $name = $_POST['field_bezeichnung'];
    $email = $_POST['field_beschreibung'];
    $phone = $_POST['field_bild'];
     ?>
    <?php
    
    if ( isset( $_POST['SUBMIT'] ) )
    {
    global $wpdb;
    $table ='wp_projekte';
    $data = array(
    'field_vorname' => $_POST['field_vorname'],
    'field_name' => $POST['field_name'],
    'field_email' => $_POST['field_email'],
    'field_phone' => $POST['field_phone'],
    'field_hilsorganisation' => $_POST['field_hilsorganisation'],
    'field_bezeichnung' => $POST['field_bezeichnung'],
    'name' => $_POST['user_name'],
    'field_beschreibung' => $POST['field_beschreibung'],
    'field_bild' => base64_encode(file_get_contents($_POST['field_bild'])));
    $format = array('%s','%s','%s','%s','%s','%s','%s','%s','%s');
    $wpdb->insert( $table, $data, $format );
     }
    ?>
    
     <html>
     <head>
        <title> Projekte </title>
     </head>
     <body>
        <form  method='POST'>
                <label>Vorname</label> <input type='text' name='field_vorname'> <br/>
                <label>Name</label> <input type='text' name='field_name'> <br/>
                <label>E-mail</label> <input type='text' name='field_email'> <br/>
                <label>Telefon</label> <input type='text' name='field_phone'>  <br/>
                <label>Hilfsorganisation</label> <input type='text' name='field_hilsorganisation'> <br/>
                <label>Projektbezeichnung</label> <input type='text' name='field_bezeichnung'> <br/>
                <label>Projektbeschreibung</label> <textarea type='text' name='field_beschreibung'></textarea> <br/>
                <label>Bild für Projekt</label> <span class="wpcf7-form-control-wrap file-894"> <br/> <br/>
                <input type="file" name="file-894" size="40" class="wpcf7-form-control wpcf7-file wpcf7-validates-as-required" accept=".png,.jpg" aria-required="true" aria-invalid="false"></span>
                <br/>
                <br/>
            <input type='submit' name ='submit' value='SUBMIT'>
     </form>
     </body>
     </html>
Ansicht von 1 Antwort (von insgesamt 1)
  • Moderator Bego Mario Garde

    (@pixolin)

    Moderation Note:

    I have closed this thread because you asked your question in English in the German support forums. To keep the threads accessible for users who don’t speak English, please ask your question in German or post it in the international support forums. Thanks for your understanding.

Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „PHP Send Form Data to WordPress Database“ ist für neue Antworten geschlossen.