₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,664 members, 8,427,500 topics. Date: Tuesday, 16 June 2026 at 04:21 AM

Toggle theme

Please Kindly Help With This JSON Code - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPlease Kindly Help With This JSON Code (1262 Views)

1 Reply (Go Down)

Please Kindly Help With This JSON Code by ptassystems(op): 1:20pm On Aug 19, 2015
Am trying to code this into a contact form on a website, but its delivering an empty message. Please someone should help me check the code.

<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contacting us. As early as possible we will contact you '
);

$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));

$email_from = $email;
$email_to = 'mail@email.com';//email address to receive message

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;

?>


Thanks
Re: Please Kindly Help With This JSON Code by thewebcraft(m): 4:15pm On Aug 19, 2015
The code works, are you trying to read the json?
Re: Please Kindly Help With This JSON Code by ptassystems(op): 4:55pm On Aug 19, 2015
Am trying to use it on the contact page of a website, but whenever the contact form is filled, the message posted are not delivered to the mail. Only an empty message is delivered.

The Email, Name, Subject and Message sent are not delivered, just an empty mail.
Re: Please Kindly Help With This JSON Code by Nobody: 5:34pm On Aug 19, 2015
ptassystems:
Am trying to code this into a contact form on a website, but its delivering an empty message. Please someone should help me check the code.

<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contacting us. As early as possible we will contact you '
);

$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));

$email_from = $email;
$email_to = 'mail@email.com';//email address to receive message

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;

?>


Thanks
una too lyk stress .use Google form
www.nairaland.com/2536824/html-contact-form-gurus
Re: Please Kindly Help With This JSON Code by jacob05(m): 6:11pm On Aug 19, 2015
ptassystems:
Am trying to use it on the contact page of a website, but whenever the contact form is filled, the message posted are not delivered to the mail. Only an empty message is delivered.

The Email, Name, Subject and Message sent are not delivered, just an empty mail.
probably you should check your HTML form... or paste it
Re: Please Kindly Help With This JSON Code by Nobody: 10:25pm On Aug 19, 2015
When you put error surpression for the mail function nko? how are we to know what happened?
Re: Please Kindly Help With This JSON Code by babatope88(m): 12:06am On Aug 20, 2015
Sai baba
Re: Please Kindly Help With This JSON Code by ptassystems(op): 3:22am On Aug 20, 2015
<div class="row contact-wrap">
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="POST" action="sendemail.php">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" class="form-control" required="required">
</div>
<div class="form-group">
<label>Phone *</label>
<input type="number" class="form-control">
</div>
<div class="form-group">
<label>Company Name</label>
<input type="text" class="form-control">
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
</div>

This is the form. Thanks to programmers willing to help
Re: Please Kindly Help With This JSON Code by Nobody: 4:32am On Aug 20, 2015
babatope88:
Sai baba
Sai Omo!

@op, you are welcome o jare.
1 Reply

Professional Html,bootstrap,php,java,json Web Deloper. Pay After Service!Jamb Past Questions API In JSONProgramming Challenge: Convert String to Json with a Loop234

How To Add Page Title As H1 Tag On Wordpress Loop?List Out The New AnimesNew Feature Lists For Nairaland In 2018