Form not working

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 1438 Views - Last Post: 25 September 2017 - 12:23 PM Rate Topic: -----

#1 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Form not working

Posted 21 September 2017 - 07:20 AM

I just looked at my processing code and it says two errors. but I don't get it.

http://www.empowered...Classifieds.php

<?php
  $pageTitle = " Contact";
  include('inc/header.php');
 
?>
 <div class="container bg-color">
      <div class="row">
            <div  style="padding-top: 15px;">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                                     <ol class="carousel-indicators">
                        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                        <li data-target="#myCarousel" data-slide-to="1"></li>
                        <li data-target="#myCarousel" data-slide-to="2"></li>
                        <li data-target="#myCarousel" data-slide-to="3"></li>
                        <li data-target="#myCarousel" data-slide-to="4"></li>
                    </ol>

                    <!-- Wrapper for slides -->
                     <div class="carousel-inner" role="listbox">
                        <div class="item active">
 <img src="img/AdobeStock_83234383.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/AdobeStock_110313737.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/AdobeStock_72595945.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/image5675.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/image6633.jpg" alt="" width="1920" height="546">
</div>
                    </div>

                    <!-- Left and right controls -->
                    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                        <span class="sr-only">Next</span></a>
                        </div>  
                </div>
            </div>
        </div>
     &nbsp;
        <div class="container bgWhite">
        <div id="title">
         <div class="left">Submission Form</div>
         <div class="right"><a href="https://www.facebook.com/groups/637729496399795/" target="_blank"><img src="img/Facebook.jpg" width="50" height="50" alt="Facebook"/></a>&nbsp;&nbsp;<a href="https://twitter.com/EmpoweredGolf" target="_blank"><img src="img/twitter.jpg" width="50" height="50" alt="Twitter"/></a></div>
        </div>
         </div>
     &nbsp;
        <div class="container bgWhite">
        
    <form action="form_process.php" method="post" name="contact_form">
     &nbsp;
      <h4><strong>First Name:
      </strong>
        <input name="first_name" type="text"/>
      </h4>
      <h4>
        
        <strong>Last Name:</strong>
        <input name="last_name" type="text"/>
      </h4>
      <h4>  
        
        <strong>Email Address:</strong>
        <input name="email" type="text"/>
      </h4>
      <h4>
        For Sale:
        <input type="radio" name="radio" id="for sale" value="for sale"/>
      </h4>
      <h4>
       Wanted:
        <input type="radio" name="radio" id="wanted" value="wanted"/>
      </h4>
      <h4><p>
		  <label for="textarea"><strong>Advertisement:</strong></label>
        <textarea name="advertisement"></textarea>&nbsp;</p></h4>
      <p>
        <input type="submit" name="submit" id="submit" value="Submit">
        <input type="reset" name="reset" id="reset" value="Reset">
      </p>
      
    
    
    </form>  

</div>


<?php include('inc/footer.php'); ?>


<?php

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];

<input type="radio" name="For Sale" value="For Sale"/>
    
<input type="radio" name="Wanted" value="Wanted"/>
    

    

$advertisement = $_POST['advertisement'];

$to = "[email protected]";
$subject = "New Advertisement";

mail ($to, $subject, $advertisement "From: " . $first_name . $last_name);
echo "Your Advertisement has been sent";

?>


Is This A Good Question/Topic? 0
  • +

Replies To: Form not working

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,843
  • Joined: 12-June 08

Re: Form not working

Posted 21 September 2017 - 07:30 AM

What errors?
Was This Post Helpful? 0
  • +
  • -

#3 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 21 September 2017 - 07:38 AM

When I fill out the form I get an error. Would you mind trying it?

http://www.empowered...Classifieds.php
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Form not working

Posted 21 September 2017 - 08:14 AM

Post the error details here.
Was This Post Helpful? 0
  • +
  • -

#5 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 21 September 2017 - 11:31 AM

The error happens when you click on submit and you get the following.

http://www.empowered...orm_process.php

This post has been edited by Maxx5: 21 September 2017 - 11:33 AM

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Form not working

Posted 21 September 2017 - 01:13 PM

Once more, tell us what the error is, stop pointing us to an external page. If something happens, rather than you seeing an error message, then describe what happens: exactly.

But... you said "and it says two errors." so just tell us what they say.
Was This Post Helpful? 0
  • +
  • -

#7 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 21 September 2017 - 02:08 PM

I get an error for the following line.

<input type="radio" name="For Sale" value="For Sale"/>

syntax error, unexpected '<'

And


mail ($to, $subject, $advertisement "From: " . $first_name . $last_name);

syntax error, unexpected quoted-string (T_CONSTANT_ENCAPSED_STRING)
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Form not working

Posted 21 September 2017 - 11:38 PM

In the second line, which is the quoted string? "From:" Why is it unexpected? Because there is nothing between it and $advertisement.

For the first line, why would the HTML symbol '<' be unexpected? We cannot tell from the posting of this single line, but it seems likely that it is expecting a PHP statement, rather than some HTML. Check the code before, and around, this line, and post it if you still cannot see why it is an issue.

This also turns out to be a question about PHP code, not HTML/CSS. Moving topic.
Was This Post Helpful? 0
  • +
  • -

#9 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 22 September 2017 - 07:58 AM

Ok what I did was remove the code regarding the following.

<input type="radio" name="For Sale" value="For Sale"/>
<input type="radio" name="Wanted" value="wanted"/>

Because it's HTML and did not belong there. The forum works now except for the processing of the radio buttons.I try googling how to process radio buttons but it keeps giving me the HTML side of it. What should I be searching for. For my answer.
Was This Post Helpful? 0
  • +
  • -

#10 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • Posts: 13,467
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 08:08 AM

Radio buttons are HTML. PHP has nothing to do with them. PHP processes the data as submitted by the HTML form.
Was This Post Helpful? 0
  • +
  • -

#11 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 22 September 2017 - 08:16 AM

Ok, I guess What I'm saying is the processing part for the radio buttons I don't have. This is what I have so far.


<?php

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];


		
$advertisement = $_POST['advertisement'];

$to = "[email protected]";
$subject = "New Advertisement";

mail ($to, $subject, $advertisement . "From: " . $first_name . $last_name);

echo "Your Advertisement has been sent";

?>

Was This Post Helpful? 0
  • +
  • -

#12 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • Posts: 13,467
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 08:53 AM

Taking the form from here:
    <form method="post" action="./test.php">
        <input type="radio" name="gender" value="male" checked> Male<br>
        <input type="radio" name="gender" value="female"> Female<br>
        <input type="radio" name="gender" value="other"> Other<br>
        <input type="submit" value="Submit">
    </form>


and using this as test.php:
<?php
var_dump($_POST);
?>


My result when simply clicking submit:
array (size=1)
  'gender' => string 'male' (length=4)


Oh, and $x = $_POST['x]; is pointless. Why store the same value in two variables?
Was This Post Helpful? 0
  • +
  • -

#13 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 22 September 2017 - 08:59 AM

I'm just a wee confused what you're saying. But I guess I should have shown what I have for my HTML end of things.


<?php
  $pageTitle = " Contact";
  include('inc/header.php');
 
?>
 <div class="container bg-color">
      <div class="row">
            <div  style="padding-top: 15px;">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                                     <ol class="carousel-indicators">
                        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                        <li data-target="#myCarousel" data-slide-to="1"></li>
                        <li data-target="#myCarousel" data-slide-to="2"></li>
                        <li data-target="#myCarousel" data-slide-to="3"></li>
                        <li data-target="#myCarousel" data-slide-to="4"></li>
                    </ol>

                    <!-- Wrapper for slides -->
                     <div class="carousel-inner" role="listbox">
                        <div class="item active">
 <img src="img/AdobeStock_83234383.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/AdobeStock_110313737.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/AdobeStock_72595945.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/image5675.jpg" alt="" width="1920" height="546">
</div>
<div class="item">
 <img src="img/image6633.jpg" alt="" width="1920" height="546">
</div>
                    </div>

                    <!-- Left and right controls -->
                    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                        <span class="sr-only">Next</span></a>
                        </div>  
                </div>
            </div>
        </div>
     &nbsp;
        <div class="container bgWhite">
        <div id="title">
         <div class="left">Submission Form</div>
         <div class="right"><a href="https://www.facebook.com/groups/637729496399795/" target="_blank"><img src="img/Facebook.jpg" width="50" height="50" alt="Facebook"/></a>&nbsp;&nbsp;<a href="https://twitter.com/EmpoweredGolf" target="_blank"><img src="img/twitter.jpg" width="50" height="50" alt="Twitter"/></a></div>
        </div>
         </div>
     &nbsp;
        <div class="container bgWhite">
        
    <form action="form_process.php" method="post" name="contact_form">
     &nbsp;
      <h4><strong>First Name:
      </strong>
        <input name="first_name" type="text"/>
      </h4>
      <h4>
        
        <strong>Last Name:</strong>
        <input name="last_name" type="text"/>
      </h4>
      <h4>  
        
        <strong>Email Address:</strong>
        <input name="email" type="text"/>
      </h4>
      <h4>
        For Sale:
        <input type="radio" name="radio" id="for sale" value="for sale"/>
      </h4>
      <h4>
       Wanted:
        <input type="radio" name="radio" id="wanted" value="wanted"/>
      </h4>
      <h4><p>
		  <label for="textarea"><strong>Advertisement:</strong></label>
        <textarea name="advertisement"></textarea>&nbsp;</p></h4>
      <p>
        <input type="submit" name="submit" id="submit" value="Submit">
        <input type="reset" name="reset" id="reset" value="Reset">
      </p>
      
    
    
    </form>  

</div>


<?php include('inc/footer.php'); ?>

Was This Post Helpful? 0
  • +
  • -

#14 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • Posts: 13,467
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 09:12 AM

Change your action to test.php and make that file contain this:
<?php
var_dump($_POST);
?>


What's your output?
Was This Post Helpful? 0
  • +
  • -

#15 Maxx5  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 203
  • Joined: 15-September 15

Re: Form not working

Posted 22 September 2017 - 12:20 PM

What do you mean change my action? Sorry.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3