AMP form submission into database - php

Form Submission using Amp template is not working, I can't post data from amp-form by using php .Simply No action is getting performed. How to fix it?
Mypage: http://samiakhalil.com/theinfotime/amp/register1.php
<?php
if (isset($_POST['register'])) {
$name = $_POST['name'];
$email = $_POST['email'];
echo $name;
}
?>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<form method="post"
action-xhr="https://ampbyexample.com/components/amp-form/submit-form-input-text-xhr"
target="_top">
<input type="text" class="data-input" name="name" placeholder="Name" required>
<input type="email" class="data-input" name="email" placeholder="Email" required>
<input type="submit" value="Register" name="register" class="button button-primary">
</form>

add
<input type="hidden" name="register" value="a">
button name is empty, i dont know

Related

How to make a form disappear after submit in Wordpress plugin

I am building a WordPress plugin for my livechat. When someone downloads the plugin, I want them to fill out some information (name, e-mail, etc). After submitting that info, the form has to disappear/hide. For some reason I am not successful and imo I've tried everything. At the moment I'm trying to do it with an if-statement checking if the submit-button isset(). Unfortunately that didn't work.
Can someone please help me? The code for display the form and the page after submitting:
<?php
public function display_plugin_setup_page()
{
if (isset($_POST['submitForm'])) {
?>
<form action="options.php" method="post">
<?php
settings_fields('mister_chat_options');
do_settings_sections($this->plugin_name); ?>
<input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e('Save'); ?>" />
</form>
<?php
} else {
// create the form
?>
<form method="post" action="sendmail.php">
<input type="hidden" name="formSent">
<fieldset>
<input placeholder="Voornaam" type="text" id="vnaam" name="vnaam">
</fieldset>
<fieldset>
<input placeholder="Achternaam" type="text" id="anaam" name="anaam">
</fieldset>
<fieldset>
<input placeholder="Bedrijfsnaam" type="text" id="bnaam" name="bnaam">
</fieldset>
<fieldset>
<input placeholder="E-mailadres" type="email" id="email" name="email">
</fieldset>
<fieldset>
<input placeholder="Telefoonnummer" type="tel" id="telef" name="telef">
</fieldset>
<fieldset>
<input type="submit" name="submitForm" id="contact-submit" data-submit="...Verzenden">
</fieldset>
</form>
<?php
}
}
I placed the sendmail.php file inside the file above and that fixed my problem.

2 different action in one form

I have a form called addcustomer.php . it's contain firsname, lastname, mobile fields.i have also 2 button on this form. onr button for saving data and the others for sending sms to customers.
i want to when i click second button 3 data fields passed to another form called smsinfo.php.
now action for saving data works good but when direct to smsinfo . there is no data on this form .
<form method ="POST" name = "custform" action="">
<div class="cell_2_2"><label class="lblfields">Firstname:</label> <input type="text" name="firstname" autocomplete="off"/></div>
<div class="cell_3_2"><label class="lblfields">Lastname :</label> <input type="text" name="lastname" autocomplete="off"/></div>
<div class="cell_5_2"><label class="lblfields">Mobile :</label> <input type="text" name="mobile" autocomplete="off"/></div>
<input type="submit" name="submit" value="Save"/>
<input type="submit" name="sendsms" value="Sms"/>
if (isset($_POST['submit']))
{
Saving code here
} else if (isset($_POST['sendsms'])) {
header("Location: smsinfo.php");
}
here code of smsinfo.php:
<?php
$Fname = $_REQUEST['firstname'];
$Lname = $_REQUEST['lastname'];
$Mob = $_REQUEST['mobile'];
?>
<html>
<body>
<form action="sendingsms.php" method="POST">
<input style="width: 100px;" name="firstname" type="text" value="<?php echo $firstname; ?>"/>
<input style="width: 100px;" name="lastname" type="text" value="<?php echo $lastname; ?>"/>
<input style="width: 100px;" name="mobile" type="text" value="<?php echo $mobile; ?>"/>
</form>
</body>
</html>
thanks all and sorry for my poor english

how to get data from an html form and use it to make an email with php?

I want to send an email from the browser, but my PHP knowledge and experience are not enough.
So I have a html form
<form>
<textarea value="Message" required></textarea>
<input type="text" value="Name" required>
<input type="text" value="Email" required>
<input type="text" value="subject" required>
<input type="reset" value="Reset" >
<input type="submit" value="Submit">
</form>
My question here is how to fill this php code so I can get data from the html form and then send the email.
$to = "my_email#example.com";
$name =
$message =
$from =
$headers =
mail($to,$name,$subject,$message,$headers);
You have to add an action and a method (POST or GET) in your form
<form action="yourpage.php" method="POST">
After that add a name attribute at all your input :
<input type="text" value="Name" name="name" required>
<input type="text" value="Email" name="mail" required>
In yourpage.php
Here the method was POST so :
$_POST['name']; //Here get the posted value in input named 'name'
$_POST['mail'];
You need to set the action in the form, and get the $_POST in PHP code, here is an example:
<form action="test.php">
<textarea value="Message" required></textarea>
<input type="text" name="Name" value="Name" required>
<input type="text" name="Email" value="Email" required>
<input type="text" name="subject" value="subject" required>
<input type="reset" value="Reset" >
<input type="submit" value="Submit">
</form>
//test.php file
<?php
$to = "my_email#example.com";
$name = $_POST['Name'];
$message = $_POST['Message'];
$from = 'test#test.com';
$headers = 'your headers';
mail($to,$name,$subject,$message,$headers);
?>

Bootstrap forms: it doesn't retrive POST data. With GET it does

Implementing forms with bootstrap's classes, in a first page I wrote this code
<form action="dologin.php" method="post">
<input type="text" name="email" class="form-control" placeholder="Username">
<input type="password" name="password" class="form-control" placeholder="Password">
<input type="image" src="img/login.png" alt="Login">
</form>
and in dologin.php I tried to retrive the data in this way
$email = $_POST['email'];
echo $email;
It doesn't work, it doesn't print anything.
But if I use the get method, in first page:
<form action="dologin.php" method="get">
<input type="text" name="email" class="form-control" placeholder="Username">
<input type="password" name="password" class="form-control" placeholder="Password">
<input type="image" src="img/login.png" alt="Login">
</form>
In dologin.php
$email = $_GET['email'];
echo $email;
It works printing what was input in the form.
Thank you for helping.
I believe it has something to do with the "image" input.
have you considered using a button element instead?
<button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>
Try this :-
<form action="dologin.php" method="post">
<input type="text" name="email" class="form-control" placeholder="Username">
<input type="password" name="password" class="form-control" placeholder="Password">
<input type="image" src="img/login.png" type="submit" alt="Login">
</form>
And in dologin.php :
email = $_POST['email'];
echo $email;

$_POST returning empty value

EDIT: The code seems to work if I place the PHP code in the same file at the HTML. I'll implement this method for now. Thank you for the help!
Whenever I try to echo the values in a PHP file from an input box the values appear to be empty.
Here is my HTML code
<form action="sendmail.php" method="post">
<label>Name:</label><br>
<input name="person" type="text" /><br>
<label>Email:</label><br>
<input name="email" type="email" /><br>
<label>Opportunity:</label><br>
<textarea name="message" rows="8"></textarea><br>
<input type="submit" value="Submit" class="button">
</form>
This is my sendmail.php file
$name = $_POST['person'];
$email = $_POST['email'];
$message = $_POST['message'];
echo $name;
echo $email;
echo $message;
You can get the value in Your current page itself
<?php
if(isset($_POST['person']))
{
$name = $_POST['person'];
$email = $_POST['email'];
$message = $_POST['message'];
echo "Name".$name;
echo "Email".$email;
echo "Message".$message;
}
?>
<form action="" method="post">
<label>Name:</label><br>
<input name="person" type="text" /><br>
<label>Email:</label><br>
<input name="email" type="email" /><br>
<label>Opportunity:</label><br>
<textarea name="message" rows="8"></textarea><br>
<input type="submit" value="Submit" class="button">
</form>
or if you want the data in another page
<form action="send.php" method="post">
<label>Name:</label><br>
<input name="person" type="text" /><br>
<label>Email:</label><br>
<input name="email" type="email" /><br>
<label>Opportunity:</label><br>
<textarea name="message" rows="8"></textarea><br>
<input type="submit" value="Submit" class="button">
send.php file
<?php
if(isset($_POST['person']))
{
$name = $_POST['person'];
$email = $_POST['email'];
$message = $_POST['message'];
echo "Name".$name;
echo "Email".$email;
echo "Message".$message;
}
?>
I tried this code and it worked fine, so whatever is wrong it is not with the code you have pasted here.
to make sure the post is successful, try this:
if(isset($_POST['person']))
echo "passed fine.";
check:
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST'){
if(isset($_POST['person'])){
$name = $_POST['person'];
echo $name;
}
}
else{
echo"Your form submission is not correct";
}
try this code.
HTML
<form action="sendmail.php" method="post">
<label>Name:</label><br>
<input name="person" type="text" /><br>
<label>Email:</label><br>
<input name="email" type="email" /><br>
<label>Opportunity:</label><br>
<textarea name="message" rows="8"></textarea><br>
<input type="submit" value="Submit" class="button">
</form>
PHP
<?php
$name = $_POST['person'];
$email = $_POST['email'];
$message = $_POST['message'];
echo $name;
echo $email;
echo $message;
?>
<form action="456.php" method="post">
<label>Name:</label><br>
<input name="person" type="text" /><br>
<label>Email:</label><br>
<input name="email" type="email" /><br>
<label>Opportunity:</label><br>
<textarea name="message" rows="8"></textarea><br>
<input type="submit" value="Submit" class="button">
</form>
<?
print_r($_POST);
?>

Categories