Jump to content

Run php in a table cell


phpsupernoob4

Recommended Posts

Hi, I am essentially trying to add a welcome/logon part to my site. So as you can see the idea of this script is to welcome the customer, get them to sign in or register, however I would like when the person clicks on "Log in" for my login script to appear in this cell (so they dont leave the page), yet I am at a loss for how to do it!! Help please

 

session_start();

if($_SESSION['username'])

echo "Welcome $firstname";

else

echo

'<html>Welcome!

<a href="/login.php">Log in</a>

<br>

Not an existing customer? <a href="/register.php">Sign up</a>

</html>';

Link to comment
https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/
Share on other sites

Sorry I am very new to this, I still don't understand how I define the text as the variable? So that if it is clicked it does the load action?

 

should it look something like this?

 

<div id="login">Log in</div>

<script>

$("#login").load("login.php");

</script>

If I hide with CSS it will take up extra space as it would be text + form?

Could someone provide code here and possibly explain, as I said I am new to this, I am attempting to learn javascript but I still have no idea how to make the text the variable to either load or unhide the form....

Oh, you want to simply toggle visibility of a cell?

I was under the impression that you wanted to inject a page onclick.

My mistake. Disregard my post.

If you want the element hidden without it taking up it designated space, use display: none;

No I think your original answer was closer to what I wanted to do, I want the cell to have its current content removed and replaced with the load, I am still trying to get to grips with the link you sent but it is a bit above me.

 

So far to make the words login I found the idea of

 

<a href="javascript:;" onclick="document.FORM NAME.load();">Login</a>

 

so then I can run the load script, to remove the current contents and replace it with the login.php form. How that code would look I have no idea yet, or how it is done

Then you really have two options, you can integrate the login.php script into the page that you want to call it from, and simply toggle its visibility onclick (I think xyph was after this solution).

Or you can use jquery and the .load() function (using the links I provided) to load the script into a specified element onclick.

To use jquery you will need to have the library on your server or link to an external repository (google and several others host the lib).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.