I have a contact form on my website using Unirest I am trying to POST data to Trello API creating a card. Keep getting error 500. Here are index.html and contact.php that I have. https://trelloapi.yetitech.nz/yetitech-trello-int/
<body>
<div class="wrapper">
<div id="contact-form">
<div class="container">
<form action="contact.php" method="POST">
<input type="text" name="Name" placeholder="Name" class="form-control" />
<input type="email" name="email" placeholder="eMail" class="form-control" />
<input type="text" name="Business_Name" placeholder="Business Name" class="form-control" />
<input type="tel" name="Contact_Phone" placeholder="Contact Phone" class="form-control" />
<select name="type">
<option value="Website">Website</option>
<option value="software">Software</option>
<option value="hosting">Hosting</option>
</select>
<input type="text" name="Message" placeholder="Message" class="form-control"/>
<button type="submit" value="submit" name="submit"> Submit</button>
<!-- <input type="submit" name="submit" value="Submit"> -->
</form>
</div>
</div>
</div>
</body>
php script:
<?php
require_once '/src/Unirest.php';
if (isset($_POST['submit'])){
$name = $_POST['Name'];
$type = $_POST['type'];
$email = $_POST['email'];
$business_name = $_POST['Business_Name'];
$contact_phone = $_POST['Contact_Phone'];
$message = $_POST['Message'];
}
$query = array(
'key' => '{MYKEYHERE}',
'token' => '{MYTOKENHERE}',
'idList' => '{MYIDISHERE}',
'name' => $name,
'desc' => $message
);
$response = Unirest\Request::post(
'https://api.trello.com/1/cards',
$query
);
var_dump($response)
?>
I am using these API docs: https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
Can anyone see what I am missing, my error 500 isn't giving a lot of indication as the Data is parsing via the form:
Error_message
Tap on response Tab in browser you can see nearby header you show in image. then findout what be wrong with error message.
Related
I am new to web designing and i just got an assignment from my class to create a jQuery application. the application will require a user to submit a data that should be saved to a database! My friend told me that when i have created the php connection, i should save them bothe the HTML and PHP files in the database mysql folder, i use xampp as my mysql server.
Now the problem is once i click the submit button, the page loads but does not display anything and the data isnt uploaded to the database. How can i handle this to successfully upload my data to the database?
Here is my html file with the form
<form action="con.php" method="POST" enctype="multipart/form-data">
<div style="padding:20px 20px;">
<h2>Personal Details</h2>
<p>In this section, we would like you to provide your personal details.</p>
<label for="name">Name:</label>
<input type="text" name="fullname" placeholder="enter your fullname" data-theme="a" required/>
<label for="PhoneNumber">Phone Number:</label>
<input type="number" name="phonenumber" placeholder="enter your phone number" data-theme="a" required/>
<label for="mail">E-Mail:</label>
<input type="text" name="email" value=""placeholder="enter your e-mail address" data-theme="a" required/>
<div data-role="controlgroup" data-type="horizontal" data-mini="true" required/>
<h4>Gender</h4>
<input type="radio" name="gender" value="f" id="gender" required/>
<label for="gender">Female</label>
<input type="radio" name="gender" value="m" id="gender2" required/>
<label for="gender2">Male</label>
</div>
<h2>Description</h2>
<p>Provide in detail the description of the case you are reporting and to where it took place.</p>
<label for="location">Location</label>
<input type="text" name="location" placeholder="enter where you are reporting from" data-theme="a" required/>
<label for="title">Title:</label>
<input type="text" name = "title" id="title" value=""placeholder="enter the title of the case you are reporting" data-theme="a" required/>
<label for="description">Description:</label>
<textarea cols="40" rows="8" name = "description" id = "textarea" value=""placeholder="describe the case you are reporting" required/></textarea>
<div data-role="fieldcontain">
<label for="picture">Upload a picture or a video file for evidence: </label>
<input type="file" name = "image" id="picture" id="picture" required/>
</div>
<div data-role="fielcontain">
<label for="terms">Before you proceed, please read to Terms and Conditions applied. Click here to read the terms and conditions</label>
<select name="terms" id="terms" data-role="slider" data-mini="true">
<option name = "terms" value="n">Deny</option>
<option name = "terms" value="y">Agree</option>
</select>
</div>
</div>
<div data-role="fieldcontain">
<input type="submit" name = "register" value="Send"/>
</div>
</form>
And here is my PHP file
<?php
if(isset($_POST['register'])){
$fullname = $_POST['fullname'];
$phonenumber = $_POST['phonenumber'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$location = $_POST['location'];
$title = $_POST['title'];
$description = $_POST['description'];
$image = $_POST['image'];
$terms = $_POST['terms'];
//database connection
$conn = new mysqli('localhost','root','','reportapp');
//check connection
if($conn->connect_error){
die('connection failed'.$conn->connect_error);
echo "report failed";
} else{
$stmt = $conn->prepare("insert into trials(fullname,phonenumber,email,gender,location,title,description,image,terms)
values (?,?,?,?,?,?,?,?,?) ");
$stmt->bind_param("sisssssbs", $fullname, $phonenumber, $email,$gender, $location, $title, $description, $image, $terms) ;
$stmt->execute();
echo "case report success.....";
$stmt->close();
$conn->close();
}
}
?>
When ever i upload the data, it does not display the successfully message but only show a blank white page and the data is not inserted into thee database
please help me how i can successfully upload the form data to the database!
I have a simple html form what I use in all of my websites in different servers.
In a new server I found a problem I cant solve by my own.
The problem is that after hit the submit button php code doesnt send the email to the server email and doesnt direct to the thankyou.html page. But it does direct to mydomain.com/contactform.php and shows the php code. Firstly I though something wrong with the server configuration, but i didnt find anything. Could anyone give my any advice where to search? Thanks in advance!
PHP code:
<?php
if($_SERVER["REQUEST_METHOD"] === "POST") {}
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$place = $_POST['place'];
$number = $_POST['number'];
$csoportjelleg = $_POST['csoportjelleg'];
$message = $_POST['message'];
$recaptcha_secret = "secret-key";
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$_POST['g-recaptcha-response']);
$response = json_decode($response, true);
if($response["success"] === true){
$mailTo = "info#serveremail.com";
$headers = "From: ".$mailFrom;
$txt = "Feladó: ".$name."\nInnenjönnek: ".$place."\nLétszám: ".$number."\nCsoportjelleg: ".$csoportjelleg."\n\nÜzenet: ".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: thankyou");
}else{
header("Location: error");
}
}
?>
HTML code:
<form action="contactform.php" method="post" class="ajanlatkeres-form">
<h2 class="centered-h2">Általános adatok</h2>
<input type="text" name="name" placeholder="Teljes név*" class="feedback-input" required>
<input type="text" name="mail" placeholder="E-mail*" class="feedback-input" required>
<h2 class="centered-h2">További adatok</h2>
<input type="text" name="place" placeholder="Honnan jöttök?" class="feedback-input">
<input type="text" name="number" placeholder="Hány fős a csoport?" class="feedback-input">
<div class="feedback-input-div">
<p class="form-p">Csoport jelleg?</p>
<label class="container">Munkahelyi
<input type="radio" name="csoportjelleg" required>
<span class="checkmark"></span>
</label>
<label class="container">Iskolai
<input type="radio" name="csoportjelleg">
<span class="checkmark"></span>
</label>
<label class="container">Családi
<input type="radio" name="csoportjelleg">
<span class="checkmark"></span>
</label>
<label class="container">Egyéb
<input type="radio" name="csoportjelleg">
<span class="checkmark"></span>
</label>
</div>
<h2 class="centered-h2">Üzenet</h2>
<input type="hidden" name="subject" value="Csoportos ajánlatkérés">
<textarea name="message" placeholder="Ajánlatkérés üzenete:*" class="feedback-input" required></textarea>
<div class="g-recaptcha" id="rcaptcha" data-sitekey="6LdBDf4UAAAAAJ50InC0WKfVep4263x3Bmuz9-60"></div><br/>
<div class="button-form">
<button id="submit_form" class="contactbutton" type="submit" name="submit">Küldés</button>
</div>
UI.: PHP form location: I use thankyou and error without .html extension because there are no extensions in my ULR-s thanks to .htaccess manipulations. In other servers that was absolutly ok.
Updated, thanks kerbh0lz!
//I created an HTML form and created PHP code that should send the contents of the form to my database table, but while the page returns to its original state, which is fine, the data never makes it to the database -- and there is no error.
I originally tried to create a separate PHP form, but after doing some research found this to be more efficient, and cleaner. I just need it to work and to learn if it's possible of not for it to work.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$zipcode = $_POST["zipcode"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$comment = $_POST["comment"];
//connect to server
$dbhost = "localhost";
$username = "root";
$password = "";
$dbname = "point12_guestform";
$mysql = mysqli_connect($dbhost, $username, $password, $dbname);
$query = "INSERT INTO aboutpage
(firstname,lastname,zipcode,email,subject,comment) VALUES
$firstname, $lastname, $zipcode, $email, $subject, $comment";
mysqli_query($mysql, $query);
}
?>
//HTML Form code
<form method="POST" />
<br>
<fieldset>
<div class="col-50">
<input type="text" name="firstname" placeholder="First Name"
required />
</div>
<div class="col-50">
<input type="text" name="lastname" placeholder="Last Name"
required />
</div>
<div class="col-50">
<input type="number" name="zipcode" minlength="5"
maxlength="5" placeholder="Zip Code (where you live)"
required />
</div>
<div class="col-50">
<input type="email" name="email" placeholder="Email"
required />
</div>
<div class="col-50">
<select name="subject" required>
<option selected hidden value="">Please select the option
that best fits your request.
</option>
<option value = "guest">I want to be a guest on the
podcast.
</option>
<option value = "question">I have a question.</option>
<option value = "suggestion">I have a suggestion.</option>
</select>
</div>
<div class="col-50">
<textarea name="comment"
placeholder="Questions/Suggestions/Comments"></textarea>
</div>
<p>
<input class="submit" type="submit" value="Submit" />
</p>
</div>
</fieldset>
</form>
//There have been absolutely NO results and NO error messages.//HTML Form code
<form method="POST" />
<br>
<fieldset>
<div class="col-50">
<input type="text" name="firstname" placeholder="First Name"
required />
</div>
<div class="col-50">
<input type="text" name="lastname" placeholder="Last Name"
required />
</div>
<div class="col-50">
<input type="number" name="zipcode" minlength="5"
maxlength="5" placeholder="Zip Code (where you live)"
required />
</div>
<div class="col-50">
<input type="email" name="email" placeholder="Email"
required />
</div>
<div class="col-50">
<select name="subject" required>
<option selected hidden value="">Please select the option
that best fits your request.
</option>
<option value = "guest">I want to be a guest on the
podcast.
</option>
<option value = "question">I have a question.</option>
<option value = "suggestion">I have a suggestion.</option>
</select>
</div>
<div class="col-50">
<textarea name="comment"
placeholder="Questions/Suggestions/Comments"></textarea>
</div>
<p>
<input class="submit" type="submit" value="Submit" />
</p>
</div>
</fieldset>
</form>
//There have been absolutely NO results and NO error messages.
Taking all the comments into consideration, the following code would be a good start. I cannot guarantee that this will work out of the box, but it should at least show you some errors/warnings. Once you've corrected those, you can also rest assured that the data going into your DB is not vulnerable to SQL injection. You will still have to escape your output if you choose to display the user entered info.
Please notice:
Error reporting is on (How do I get PHP errors to display?)
MySQL errors will be turned into PHP exceptions (PDO::ERRMODE_EXCEPTION)
Using PDO + parameterized queries (https://phpdelusions.net)
Redirecting to self after query is executed so that a browser refresh doesn't post the data again.
HTML is cleaned up a bit
<?php
// Turn on error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Define your connection properties
$host = 'localhost';
$db = 'point12_guestform';
$user = 'root';
$pass = '';
$charset = 'utf8mb4';
// Build up your connection string and set options
// See this for more info: https://phpdelusions.net/pdo#dsn
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
// Finally, make a connection using PDO.
// This will throw an exception if something goes awry.
$pdo = new PDO($dsn, $user, $pass, $options);
// Build up your query
// Notice the query is using placeholders `?` instead of directly
// injecting user-entered (dangerous) data.
$sql = 'INSERT INTO aboutpage (firstname,lastname,zipcode,email,subject,comment) VALUES (?,?,?,?,?,?)';
$stmt = $pdo->prepare($sql);
// Finally, execute your query by passing in your data.
// This is known as a parameterized query and prevents SQL injection attacks
$stmt->execute([
$_POST["firstname"],
$_POST["lastname"],
$_POST["zipcode"],
$_POST["email"],
$_POST["subject"],
$_POST["comment"]
]);
// Redirect to self, so that a browser refresh doesn't post data again.
header('Location: '.$_SERVER['PHP_SELF']);
exit;
}
?>
<!-- I clean up some of you HTML too. -->
<form method="post">
<div class="col-50">
<label>
<input type="text" name="firstname" placeholder="First Name" required>
</label>
</div>
<div class="col-50">
<label>
<input type="text" name="lastname" placeholder="Last Name" required>
</label>
</div>
<div class="col-50">
<label>
<input type="number"
name="zipcode"
minlength="5"
maxlength="5"
placeholder="Zip Code (where you live)"
required/>
</label>
</div>
<div class="col-50">
<label>
<input type="email" name="email" placeholder="Email" required>
</label>
</div>
<div class="col-50">
<label>
<select name="subject" required>
<option selected hidden value="">Please select the option
that best fits your request.
</option>
<option value="guest">I want to be a guest on the
podcast.
</option>
<option value="question">I have a question.</option>
<option value="suggestion">I have a suggestion.</option>
</select>
</label>
</div>
<div class="col-50">
<label>
<textarea name="comment" placeholder="Questions/Suggestions/Comments"></textarea>
</label>
</div>
<p>
<input class="submit" type="submit" value="Submit"/>
</p>
</form>
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);
?>
Hi I've got a problem with submitting my own simple form in Wordpress it always redirects me to the page witch not exists. I use almost all thing for action field in form like (get_permalink,$_SERVER["PHP_SELF"]) and even did it manually.
<?php
if (isset($_POST["email"]) && $_POST["email"]) {
$content = "user email: {$_POST["email"]}; phone : {$_POST['phone']} ";
$subject = "Test email ";
$to = "some#gmail.com";
$status = wp_mail($to,$subject,$content);
}
?>
<div class="center form-wrapper">
<form action="<?php echo get_permalink(); ?>" method="post">
<h2 class="center white form-logo">
Subscribe
</h2>
<input type="text" placeholder="Enter email" name="email">
<input type="text" placeholder="Enter name" name="name">
<input type="text" placeholder="Enter phone number" name="phone">
<input type="hidden">
<input type="submit" name="submit" value="send" >
</form>