Jump to content

Search the Community

Showing results for tags 'function returning value'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. , 02:03 PM //My contact.php <!DOCTYPE html> <html> <body> <div class="col-sm-6"> <form onsubmit="return false"> <div class="form-group"> <label for="cname" class="control-label">Full Name:</label> <input type="text" class="form-control" name="cname" id="cname"> </div> <div class="form-group"> <label for="mob" class="control-label">Phone Number:</label> <input type="text" class="form-control" name="mob" id="mob"> </div> <div class="form-group"> <label for="mail" class="control-label">Email Address:</label> <input type="email" class="form-control" name="mail" id="mail"> </div> <div class="form-group"> <label for="msg" class="control-label">Message:</label> <textarea class="form-control" rows="4" name="msg" id="msg" style="resize:none"></textarea> </div> <div id="sendmsg"> </div> <button type="submit" name="sendemail" id="sendemail" class="btn btn-success">Send Message</button> </form> </div> <script src="../res/js/jquery.min.js"></script> <script src="../res/js/bootstrap.min.js"></script> <script> $(function(){ $("#sendemail").click(function(){ var err = reqfield_val(['cname', 'mob', 'mail', 'msg']); if(err == 0){ $.ajax({ type: 'post', data: $('form').serialize() }); <?php require_once('../res/php/code.php'); $res = sendemailfn(); // I want to use the function return value here ?> $("#sendmsg").text('<?=$res?>').css("opacity",'1'); } }); }); </script> </body> </html> //mail function code in code.php file <?php function sendemailfn() { if($_POST) // to prevent form submission on page reload (& on not using this condition function is returning the value) { $res = ""; $cname = $_POST['cname']; $email_from = $_POST['mail']; $mobile = $_POST['mob']; $msg = $_POST['msg']; $to = 'muzaffar527@gmail.com'; $body = 'Name'.$cname. '\nEmail'.$email_from. '\nMobile'.$mobile. '\nMessage'.$msg; $subject = 'Enquiry from www.zuhaconsultants.com'; $headers = 'From: '.$email_from."\r\n" . 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $mail_sent = mail($to, $subject, $body, $headers); if($mail_sent == true) $res = "Thank you for contacting us. We will be in touch with you very soon."; else $res = "Seems Some Error Occured."; return $res; // this value is not returned to contact.php page // if the about condition if($_POST) is not given then it is returning the value // if it is not given the page is submitting the form on page reload } } ?> Please help me get the return value $res... in the same way please note that the form should not be submitted on page reload Thanking you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.