php - saving data in JSON object and sending online -


my idea have contact form encode input data json file , sending somewhere, can access google spreadsheet, using this method.

this current php part of form:

<?php  $errors         = array();       $data           = array();        if (empty($_post['name']))     $errors['name'] = 'name required.';  if (empty($_post['email']))     $errors['email'] = 'email required.';  if (empty($_post['superheroalias']))     $errors['superheroalias'] = 'superhero alias required.';  if ( ! empty($errors)) {     $data['success'] = false;     $data['errors']  = $errors; } else {      $data['success'] = true;     $data['message'] = 'success!';}      echo json_encode($data); 

this displays success message on form, that's it. need do something information. tried add post email function, see if mail..

$to = "email@email.com";  $from = $_post['email'];  $first_name = $_post['name']; $last_name = $_post['name2']; $subject = "form submission"; $message = $first_name . " " . $last_name . " wrote following:" . "\n\n" . $_post['message']; $message2 = "here copy of message " . $first_name . "\n\n" . $_post['message'];  $headers = "from:" . $from; $headers2 = "from:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2);  

however, don't see success message , stuck @ point.

1. there reason why mail not send ?


2. how can process json object have (hopefully) generated echo json_encode($data); ?

i can provide html , js parts of form better reference, if needed.

you should receive errors/warnings in php error-log if enabled correctly. make sure set logfile path correctly in webserver configuration. verify display_errors = on set in php.ini configuration, along error_reporting = e_all

if theres no mail being sent, possibly have set smtp service. also, if on linux, check mail logs under /var/log/mail.log , see if error occurred there.

if wish process json data generate, can an: $jsondata = json_decode($data, true); , use associate array before encoding it.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -