Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
How to display $name Input that a user submitted in a form within a $alert when user pushes the submit button?

I am stuck and hoping someone can help.

I am trying to get the user's input (their $name) to show in the $alert'' when user submit form. Example: User types in to the form the following: ** Name: Joe , Tel: XXX.XXX.XXXX , Email: Joe@example.com *** and pushes submit.

-- page refreshes and says. "Message sent Joe, thank you for contacting us!"

$mail->send();
     $alert = <div class="alert-success">'
                     <span>Message sent $name, thank you for contacting us!</span> 
                    </div>'; 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to fix your typos, like this:

$mail->send();
     $alert = '<div class="alert-success">'.
                     '<span>Message sent '.$name.', thank you for contacting us!</span>'. 
                    .'</div>'; 

Now that you have a template in $alert you will need to make sure that you display it. The simplest way to do so is to echo it, like

echo $alert;

But you may need to display it somewhere else than the current position. Also, PHP is a template language as well, so in some environments you can do something like

$mail->send(); ?>
     <div class="alert-success">
                     <span>Message sent <?php echo $name; ?>, thank you for contacting us!</span> 
                    </div>
<?php
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!