0

I'm loading an external php page into a dialog on my user page (user.php). The external page (contact.php) contains a form.

I'd like to submit the form and then return a message to the user in the dialog.

When I run contact.php the form submits. I can't submit it from the dialog on user.php- I appreciate the help.

Here is the jquery from user.php

$(document).on('click', '#contact_tutor', function(){
$('div#dialog').load("contact.php?id="+uid)
.dialog({
    width: 800,
    height: 425,
    title: "Contact,
});
});

In the html on the first page (user.php)

<div id="contact_tutor" class="contact"><a href="#">Contact <?php echo $name;?></a></div>
<div id="dialog" ></div>

Here is the code from Contact.php

<?php
include_once($_SERVER['DOCUMENT_ROOT']."/MySite/php_includes/check_login_status.php");

if (isset($_POST['posted'])&& isset($_POST['message'])){
//do stuff
?>

<!DOCTYPE html>
<head>
<link rel="stylesheet" href="style/style.css">

</head>

<body>
    <form id="message" method="POST" action="<?php echo $PHP_SELF;?>" class="contact">
    <label>Your Name:</label> <input type="text" name="sender_name" value=""></br>
    <label>Email:</label><input type="text" name="sender_email" value=""></br>
    <label>Message:</label><textarea class="textbox" cols="53" rows="10" name="message" value=""></textarea>
    <input type="hidden" name="posted" value="posted">
    <input type="Submit" value="Send Message">
    </form>
        <div class="statuserror"><?php echo $err?></div>
</body>
</html>
Mobaz
  • 597
  • 3
  • 10
  • 26
  • where is your `mail(...);` function? – Funk Forty Niner Jun 14 '13 at 20:19
  • I dont want to mail the message to the other person - I want to have the person log into the site to pick up their messages - regardless - that would go into the //do stuff right? – Mobaz Jun 14 '13 at 20:21
  • ah, ok got it. I think this may be out of my league, but I'll keep thinking. – Funk Forty Niner Jun 14 '13 at 20:24
  • contact.php's form is submitting to itself(see its form action)..is that's what you intented? – harrybvp Jun 14 '13 at 20:25
  • @harrybvp yes - its working when i load contact.php into the browser, but not into the dialog – Mobaz Jun 14 '13 at 20:27
  • @Mobaz This is the part I don't quite understand *"I can't submit it from the dialog on user.php"*. Can you elaborate on that please? – Funk Forty Niner Jun 14 '13 at 20:37
  • @Fred What i mean is that when I press the submit button (once the page has loaded in the dialog box) the form wont post (see below for why it wasn't working!) – Mobaz Jun 14 '13 at 20:39
  • @Mobaz I think I'm kind of understanding what you mean now. Why not merge your entire code into the one page, the dialog itself? That could work. I answered a similar question last night to that affect, which worked. – Funk Forty Niner Jun 14 '13 at 20:39
  • @Mobaz Great! I'm glad it worked out for you then. Live and learn, I always say :) A good reference, cheers. Did you by chance use `` instead? – Funk Forty Niner Jun 14 '13 at 20:45

1 Answers1

0

Just realised the problem - I'm using a php echo to define the form's action - which doesn't work and shows up null, replaced it with the hard coded string and everything is peachy!

Mobaz
  • 597
  • 3
  • 10
  • 26