Form not working

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

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

#16 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,472
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 04:19 PM

You need to study html before continuing with php.

Start with this page: https://www.w3school.../html_forms.asp the entire page.
Was This Post Helpful? 0
  • +
  • -

#17 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 - 06:04 PM

ok, i tried what you said and then i changed the action and i did not get an email for submit. so i put everything back the way i had it before when it worked and now i get 404 error.
Was This Post Helpful? 0
  • +
  • -

#18 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,472
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 07:29 PM

Huh? What do you think I was telling you to do? Did you read the code I wanted you to use? What should it do?
Was This Post Helpful? 0
  • +
  • -

#19 dak45309  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 155
  • Joined: 22-April 13

Re: Form not working

Posted 22 September 2017 - 07:31 PM

On the <form> tag, you have 2 attributes that should always be set...they are method and action. <form method = "post" action="test.php">

That action
Was This Post Helpful? 0
  • +
  • -

#20 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,472
  • Joined: 08-August 08

Re: Form not working

Posted 22 September 2017 - 07:52 PM

And why would I have you change that action? Hint: reread my post.
Was This Post Helpful? 0
  • +
  • -

#21 Maxx5  Icon User is offline

  • D.I.C Head

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

Re: Form not working

Posted 23 September 2017 - 09:11 AM

Ok, I'm getting the hang of it now I think. After reading and trying the examples. I have things working now. But when I click one of the two radio buttons. it does not get processed, and I don't see it in the reply email.

<?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";

?>



 <form method = "post" action="test.php">
     &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>
      
      
      
  <input type="radio" name="choice" value="sale" checked>Sale<br>
  <input type="radio" name="choice" value="wanted">Wanted<br>
 
     
     
      <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>  

Was This Post Helpful? 0
  • +
  • -

#22 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Form not working

Posted 23 September 2017 - 09:29 AM

Your radio buttons are named choice but your PHP makes no reference to them so, of course, they won't appear in the email.
Was This Post Helpful? 0
  • +
  • -

#23 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,472
  • Joined: 08-August 08

Re: Form not working

Posted 23 September 2017 - 09:37 AM

Did you try my version of test.php? You didn't show us the results as requested. If you had tried it you would see the key value pairs that get posted.
Was This Post Helpful? 0
  • +
  • -

#24 Maxx5  Icon User is offline

  • D.I.C Head

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

Re: Form not working

Posted 23 September 2017 - 12:55 PM

I added PHP to my buttons, and this is what I have.

<form method = "post" action="test.php">
     &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>
      
      
      
  <input type="radio" name="choice" value="sale" checked>Sale<br>
  <input type="radio" name="choice" value="wanted">Wanted<br>
 
     
     
      <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>  




<?php


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

if (isset($_POST['choice']))(
	
$choice = $_POST['choice'];	
echo ("Your Best Choice is". $choice);

)
	else{
	echo("No Choice Selected!");	
	}
		
$advertisement = $_POST['advertisement'];

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

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

echo "Your Advertisement has been sent";

?>



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

#25 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Form not working

Posted 23 September 2017 - 02:14 PM

So... what happens when you run it? What are you expecting to happen?
Was This Post Helpful? 0
  • +
  • -

#26 Maxx5  Icon User is offline

  • D.I.C Head

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

Re: Form not working

Posted 23 September 2017 - 02:22 PM

It works. Just not seeing the button replays.
Was This Post Helpful? 0
  • +
  • -

#27 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Form not working

Posted 23 September 2017 - 02:34 PM

What is a "button replay"? Please take more time to create clear posts.

Your if statement has syntax errors.
Was This Post Helpful? 0
  • +
  • -

#28 Maxx5  Icon User is offline

  • D.I.C Head

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

Re: Form not working

Posted 24 September 2017 - 12:21 PM

Before I go any further. I am working with the errors. The validator says there is an error in following.


F$choice = $_POST['choice'];

ATAL ERROR syntax error, unexpected ';'
Was This Post Helpful? 0
  • +
  • -

#29 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Form not working

Posted 24 September 2017 - 12:24 PM

Code blocks are identified by curly braces, not parentheses.
Was This Post Helpful? 0
  • +
  • -

#30 Maxx5  Icon User is offline

  • D.I.C Head

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

Re: Form not working

Posted 24 September 2017 - 12:41 PM

I changed it to the following and got the same error. And I did understand what you meant by curly braces, not parentheses

FATAL ERROR syntax error, unexpected ';' on line number 10


<?php


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

if (isset($_POST['choice']))(
        
$choice = $_POST{'choice'};     
echo ("Your Best Choice is". $choice);

)
        else{
        echo("No Choice Selected!");    
        }
                
$advertisement = $_POST['advertisement'];

$to = "buyandse[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
  • +
  • -

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