Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 575011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:53:33+00:00 2026-05-13T13:53:33+00:00

I’m having a hard time getting the answer for this… Am I able to

  • 0

I’m having a hard time getting the answer for this…

Am I able to get html elements from a php file with ajax? I have a feeling I’m trying to do something I’m not supposed to do.

I’m using:

.
.
.
<tr>
        <td colspan="3" style="font-size:11px;"><a href="javascript:void(0)" onclick="getData('includes/forgot-passwordajax.php', 'targetDiv')">Forgot Password?</a></td>
    </tr>


   </table></td>
  </tr>
 </table>
</form>
    <div id="targetDiv">
    </div>

And includes/forgot-passwordajax.php is a table with form data, etc. Is this supposed to work?

Edit: Here is the script:

<script language = "javascript">
      var XMLHttpRequestObject = false;

      if (window.XMLHttpRequest) {
        XMLHttpRequestObject = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
      }

      function getData(dataSource, divID)
      {
        if(XMLHttpRequestObject) {
          var obj = document.getElementById(divID);
          XMLHttpRequestObject.open("GET", dataSource);

          XMLHttpRequestObject.onreadystatechange = function()
          {
            if (XMLHttpRequestObject.readyState == 4 &&
              XMLHttpRequestObject.status == 200) {
                obj.innerHTML = XMLHttpRequestObject.responseText;
            }
          }

          XMLHttpRequestObject.send(null);
        }
      }
    </script>

php:

<?php           
<div class='a_login'>
<table class="tabbody"> 
    <tr class="tprowbgcolor">
    <td class="title">Retrieve Password</td></tr>
</table>
<center><BR><BR>
    <table cellpadding="0" cellspacing="0">
    <form name='loginForm' action="forgot-password.php" method="POST">
    <tr><td><img src="<?=SITE_URL?>/images/top-bg.jpg"></td></tr>
    <tr>
    <td class="a_td_color" align="center" valign="top">


    if(isset($_POST['formSubmitted']))
    {
    $email = addslashes(trim($_POST['e_address']));

    if($email=="")  {
      echo '<p>Just kidding? Ehh! <a href="forgot-password.php">try again</a></p>';
    } else  {
      $query    =   "SELECT `Password`, `UserName` FROM users WHERE `Email`='$email'";

      $result   =   mysql_query($query);

      if(mysql_num_rows($result)>0)  {
        $row = mysql_fetch_assoc($result);

        $password=$row['Password'];
        $username=$row['UserName'];
        $to = $email;
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'To: '.$username.' <'.$email.'>' . "\r\n";
        $headers .= 'From: Joel Laviolette <admin@mbira.me>' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
        $subject = "Here is your password";
        $message = '<p>Hello '.$username.',</p><p>Your password is: ';
        $message .= '<strong>'.$password.'</strong><br><br>';
        $message .= 'You can login here: <a href="'.SITE_URL.'/login2.php">'.SITE_URL.'/login2.php</a></p>';
        $message .= '<p>With Love and gratitude,<br>Joel Laviolette</p>';
        if(mail($to, $subject, $message, $headers)) {
          echo '<p>Your password has been sent. Please check your email.</p>';
        } else  {
          echo '<p>Email could not be sent! Please contact me directly at joel@rattletree.com.</p>';
        }
      } else  {
        echo '<p>Email not found! <a class="external" href="forgot-password.php">try again</a></p>';
      }
    }
    } else  {

  <table border='0'>
    <tr>
        <td colspan="3">
    <p>Email Address<br />
    <input type="text" name="e_address" value="" size="20"></p></td>
    </tr>
    <tr>
        <td colspan="3" align="center"><input type="submit" value="Submit" name="submit"><input type="hidden" name="formSubmitted" value='1'></td>
    </tr>
    <tr>
        <td colspan="3">&nbsp;</td>
    </tr>
    </table>
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:53:33+00:00Added an answer on May 13, 2026 at 1:53 pm

    From the PHP you posted, it looks like you enclosed HTML code in <?php ... ?> tags. That is incorrect. You should enclose the PHP code in the tags and leave the HTML outside. And you have an unclosed brace at the end. In your case, that should be (untested):

    <div class='a_login'>
    <table class="tabbody"> 
        <tr class="tprowbgcolor">
        <td class="title">Retrieve Password</td></tr>
    </table>
    <center><BR><BR>
        <table cellpadding="0" cellspacing="0">
        <form name='loginForm' action="forgot-password.php" method="POST">
        <tr><td><img src="<?=SITE_URL?>/images/top-bg.jpg"></td></tr>
        <tr>
        <td class="a_td_color" align="center" valign="top">
    
    <?php           
        if(isset($_POST['formSubmitted'])) {
          $email = addslashes(trim($_POST['e_address']));
    
          if($email=="")  {
            echo '<p>Just kidding? Ehh! <a href="forgot-password.php">try again</a></p>';
          } else  {
            $query    =   "SELECT `Password`, `UserName` FROM users WHERE `Email`='$email'";
    
            $result   =   mysql_query($query);
    
            if(mysql_num_rows($result)>0)  {
              $row = mysql_fetch_assoc($result);
    
              $password=$row['Password'];
              $username=$row['UserName'];
              $to = $email;
              $headers  = 'MIME-Version: 1.0' . "\r\n";
              $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
              $headers .= 'To: '.$username.' <'.$email.'>' . "\r\n";
              $headers .= 'From: Joel Laviolette <admin@mbira.me>' . "\r\n" .
              'X-Mailer: PHP/' . phpversion();
              $subject = "Here is your password";
              $message = '<p>Hello '.$username.',</p><p>Your password is: ';
              $message .= '<strong>'.$password.'</strong><br><br>';
              $message .= 'You can login here: <a href="'.SITE_URL.'/login2.php">'.SITE_URL.'/login2.php</a></p>';
              $message .= '<p>With Love and gratitude,<br>Joel Laviolette</p>';
              if(mail($to, $subject, $message, $headers)) {
                echo '<p>Your password has been sent. Please check your email.</p>';
              } else  {
                echo '<p>Email could not be sent! Please contact me directly at joel@rattletree.com.</p>';
              }
            } else  {
              echo '<p>Email not found! <a class="external" href="forgot-password.php">try again</a></p>';
            }
          }
        } else {
    ?>
    
      <table border='0'>
        <tr>
            <td colspan="3">
        <p>Email Address<br />
        <input type="text" name="e_address" value="" size="20"></p></td>
        </tr>
        <tr>
            <td colspan="3" align="center"><input type="submit" value="Submit" name="submit"><input type="hidden" name="formSubmitted" value='1'></td>
        </tr>
        <tr>
            <td colspan="3">&nbsp;</td>
        </tr>
        </table>
    
    <? } ?>
    

    By the way, you could go to the page (includes/forgot-passwordajax.php) in your browser to see what the error message PHP gives.

    EDIT: Also, the HTML is a little weird – the form is never closed, and it’s unclear which parts should show up when the form is first shown and which should show after the form had been submitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.