H1 Element

A

Anonymous

Guest
Hello I am trying to get a H1 element into a variable in my PHP my code here is my code:
Code:
<main>
      <form class="contact-form" action="contactform.php" method="post" enctype="multipart/form-data">
          <h1 name="product-name">1x1Logo</h1>
        <div class="txtb">
          <label>Vollständiger Name</label>
          <input type="text" name="name" value="" placeholder="Vollständiger Name">
        </div>

        <div class="txtb">
          <label>Farbe</label>
          <input type="text" name="color" value="" placeholder="Wählen Sie eine Farbe.">
        </div>

        <div class="txtb">
          <label>E-Mail</label>
          <input type="text" name="mail" value="" placeholder="Ihre E-Mail">
        </div>

        <div class="txtb">
          <label>Telefonnummer</label>
          <input type="text" name="phone" value="" placeholder="Ihre Telefonnummer(nicht notwendig)">
        </div>
          <input type="file" name="attachment">
        <div class="txtb">
          <label>Botschaft</label>
          <textarea name="message" placeholder="Schreiben..."></textarea>
        </div>
        <div class="submit-btn">
          <button type="submit" name="submit">Senden</button>
        </div>
        <div class="help-btn">
          <a type="submit" name="help">Um Rat fragen</a>
        </div>
      </form>
    </main>

Code:
<?php

if (isset($_POST['submit'])) {
  $product = $_POST['product-name'];
  $name = $_POST['name'];
  $color = $_POST['color'];
  $mailFrom = $_POST['mail'];
  $phone = $_POST['phone'];
  $message = $_POST['message'];

  $mailTo = "test@victorogsigrid.dk";
  $headers = "From: ".$mailFrom;
  $txt = "You have received an e-mail from ".$name.".\n\n"."Product: ".$product.".\n\n"."Color: ".$color.".\n\n"."Mail/Phone: ".$mailFrom."/".$phone.".\n\n"."User Wrote: ".$message;

  mail($mailTo, $product, $txt, $headers);
  header("Location: ../index.php?mailsend");
  echo('Mail has been send!');
}

?>

Any help?
 
What is your problem? Explain clearly what you expect to happen and what actually happens.

Your PHP code has problems.
 
I want to get my H1 element into the product_name variable in my PHP code (sorry for the late answer)
 
You don't have a "product_name" variable?

Your problem has not been explained clearly, without knowing what you expect and what you are struggling with, I cannot help you.

Do you know how to set a variable?
 
First of all you can't use h1 element tag you need to use an input of some sort:

for example:

Code:
<input class="image-upload" type="file" name="file">

where you can call name="file" this name="product" if you want, but I normally don't do that.

You don't have to do it this you can use a selection element which I think you are more after, but first things first. That is to get the code to work correctly. Then you would do something line the follow (that is if you want to process the image itself) :

Code:
$product = $_FILES['file']['tmp_name'];

then process of that file can occur.

However, I think you are more after something like the following:

Code:
<select name="product" id="product">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

If you want to "display" the image of the product then I would recommend using radio or check boxes instead.
 
Back
Top