Jump to content

Hello I'm trying to make a contact form and I'm trying to do the back end of the form right now and I think I'm messing something up? Hope someone can tell me what I'm doing wrong. 

Here is the code 

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$mc_username = $_POST['mc_username'];
$radio = $POST['radio'];
$message = $_POST['message']; 
$formcontent="From: $name \n Message: $message";
$recipient = "danielh9099@gmail.com";
$subject = "CSMA Website Client" + $first_name + "Service: " + $radio + "";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!"; 

 

Link to comment
https://linustechtips.com/topic/550052-php-help/
Share on other sites

Link to post
Share on other sites

I'm not sure but doesn't PHP use "." for concatenation ?

"String ".$variable." string2"

Also, IIRC you can just do something like this:

"String $variable String2"

 

CPU: Intel i5-4590 | Motherboard: Asus H97M-E | GPU: Sapphire Nitro R9 390 | RAM: 2x4Gb Kingston HyperX Fury Black | SSD: Sandisk Plus 240Gb HDD: Seagate 250Gb  | PSU: Seasonic G650 80+ Gold | Case: NZXT S340

I am who I am.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262472
Share on other sites

Link to post
Share on other sites

Also, are you sure those $_POST['variables']; getting the right values ?

CPU: Intel i5-4590 | Motherboard: Asus H97M-E | GPU: Sapphire Nitro R9 390 | RAM: 2x4Gb Kingston HyperX Fury Black | SSD: Sandisk Plus 240Gb HDD: Seagate 250Gb  | PSU: Seasonic G650 80+ Gold | Case: NZXT S340

I am who I am.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262493
Share on other sites

Link to post
Share on other sites

2 minutes ago, Danielh90 said:

 I have name="first_name" on the input So I think so. 

Is that on a form ?

What is the "method" on your form ?

CPU: Intel i5-4590 | Motherboard: Asus H97M-E | GPU: Sapphire Nitro R9 390 | RAM: 2x4Gb Kingston HyperX Fury Black | SSD: Sandisk Plus 240Gb HDD: Seagate 250Gb  | PSU: Seasonic G650 80+ Gold | Case: NZXT S340

I am who I am.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262503
Share on other sites

Link to post
Share on other sites

3 minutes ago, Danielh90 said:

mail.php 

That's the action attribute.

I think it should be something like this.

<form method="POST" action="mail.php">

 

CPU: Intel i5-4590 | Motherboard: Asus H97M-E | GPU: Sapphire Nitro R9 390 | RAM: 2x4Gb Kingston HyperX Fury Black | SSD: Sandisk Plus 240Gb HDD: Seagate 250Gb  | PSU: Seasonic G650 80+ Gold | Case: NZXT S340

I am who I am.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262521
Share on other sites

Link to post
Share on other sites

Here is my HTML code. 

<div class="row">
    <form class="col s12" action="mail.php" method="POST">
      <div class="row">
        <div class="input-field col s6">
          <input placeholder="First Name" name="first_name" type="text" class="validate">
          <label for="first_name" id="contact_text">First Name</label>
        </div>
        <div class="input-field col s6">
          <input placeholder="Last Name"  name="last_name"  type="text" class="validate">
          <label for="last_name" id="contact_text">Last Name</label>
        </div>
        <div class="row"> 
       <div class="input-field col s12">
          <input placeholder="Minecraft Username"  name="mc_username" required="required"  type="text" class="validate">
          <label for="mc_username" id="contact_text">Minecraft Username (If I join your server I know who to PM)</label>
        </div>
          </div>
      <div class="row">
        <div class="input-field col s12">
          <input placeholder="Email" type="email" name="email"  class="validate">
          <label for="password" id="contact_text">Email</label>
        </div>
      </div>
        <label for="last_name" id="contact_text" name="radio" class="active">Somthing</label>
       <p>
            <input name="group1" type="radio" id="service1" name="radio" checked="">
            <label for="service1">Something Goes here</label><a href="services.php"><i class="fa fa-question"></i></a>
          </p>
          <p>
        <input name="group1" type="radio" name="radio" id="service2"  id="radio" >
            <label for="service2">Something Goes here</label><a href="services.php"><i class="fa fa-question"></i></a>
          </p>
          <p>
            <input name="group1" type="radio" id="service3">
            <label for="service3">Something Goes here</label><a href="services.php"><i class="fa fa-question"></i></a>
          </p>
      <div class="row">
              <div class="input-field col s12">
                <textarea placeholder="Message" id="icon_prefix2" name="message"  class="materialize-textarea" style="height: 22px;"></textarea>
                <label for="icon_prefix2" class="" id="contact_text">Message</label>
              </div>
            </div>
            <button class="btn waves-effect waves-light" type="submit" name="action">Submit
    <i class="material-icons right">send</i>
  </button>
    </form>

 

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262526
Share on other sites

Link to post
Share on other sites

6 minutes ago, Danielh90 said:

Ok :) fixed that. but still gettings errors. 

Hmm . . .

That was my last idea.

I can't test it since I'm not a home and I don't have the resources.

 

Wild guess:

Can you change that button to an input ? (I'm out of ideas here. :D)

CPU: Intel i5-4590 | Motherboard: Asus H97M-E | GPU: Sapphire Nitro R9 390 | RAM: 2x4Gb Kingston HyperX Fury Black | SSD: Sandisk Plus 240Gb HDD: Seagate 250Gb  | PSU: Seasonic G650 80+ Gold | Case: NZXT S340

I am who I am.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7262568
Share on other sites

Link to post
Share on other sites

Also you might want to look at string escaping if you will want to add this messages into a database. ( http://php.net/manual/ro/mysqli.real-escape-string.php ). Another tip would be to always work on a server, you can find really cheap (and even free ) website hosting on the interwebz.

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7265953
Share on other sites

Link to post
Share on other sites

10 hours ago, WingmanImd said:

Also you might want to look at string escaping if you will want to add this messages into a database. ( http://php.net/manual/ro/mysqli.real-escape-string.php ). Another tip would be to always work on a server, you can find really cheap (and even free ) website hosting on the interwebz.

Ok Thank you. I don't what to upload the files yet because the projcet is not done yet. 

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7270088
Share on other sites

Link to post
Share on other sites

7 hours ago, Mr. E said:

What server are you using? If your form is on a webhosting, You might have to contact your webhost provider and ask them if they support mail() php function. If you're using XAMPP: You need to configure your ini file to allow the usage of sendmail.

Ok Thanks I figured it out :) 

Link to comment
https://linustechtips.com/topic/550052-php-help/#findComment-7278803
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×