phpsupernoob4 Posted March 12, 2012 Share Posted March 12, 2012 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/ Share on other sites More sharing options...
AyKay47 Posted March 12, 2012 Share Posted March 12, 2012 http://api.jquery.com/category/ajax/ particularly, http://api.jquery.com/load/ Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326259 Share on other sites More sharing options...
phpsupernoob4 Posted March 12, 2012 Author Share Posted March 12, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326263 Share on other sites More sharing options...
xyph Posted March 12, 2012 Share Posted March 12, 2012 Use JavaScript! No need to use jQuery for such a simple script http://blog.movalog.com/a/javascript-toggle-visibility/ Use CSS to set the default visibility of the form to hidden. Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326266 Share on other sites More sharing options...
phpsupernoob4 Posted March 12, 2012 Author Share Posted March 12, 2012 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.... Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326277 Share on other sites More sharing options...
xyph Posted March 12, 2012 Share Posted March 12, 2012 No it won't. http://webdesign.about.com/od/css/f/blfaqhidden.htm Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326294 Share on other sites More sharing options...
phpsupernoob4 Posted March 12, 2012 Author Share Posted March 12, 2012 "visibility: hidden hides the element, but it still takes up space in the layout." your link seems to contradict you... Instead of just throwing links at me, can someone actually help me so I can learn how to do this Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326354 Share on other sites More sharing options...
AyKay47 Posted March 12, 2012 Share Posted March 12, 2012 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; Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326355 Share on other sites More sharing options...
phpsupernoob4 Posted March 12, 2012 Author Share Posted March 12, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326357 Share on other sites More sharing options...
AyKay47 Posted March 12, 2012 Share Posted March 12, 2012 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). Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326372 Share on other sites More sharing options...
xyph Posted March 12, 2012 Share Posted March 12, 2012 Oh, I see where I was confused here. Perhaps if you were more descriptive of what you wanted to do, we could more accurately help you. Read up on AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/258703-run-php-in-a-table-cell/#findComment-1326411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.