
Tazz
Members-
Posts
43 -
Joined
-
Last visited
Never
Everything posted by Tazz
-
PHP frameworks are like car brands. The answer will depend on who you ask. I'm a huge codeigniter fan. Although I must admit that some frameworks are better than othere and you will have to research what framework will be best suited to your needs.
-
YourNameHere, sure, makes sense. But it works without waiting for DOM readiness as well. I just tried it again.
-
What do you mean YourNameHere? The fadeout is a jquery function therefore you need to include the jquery library. I have actually tested that code, it works just as it is there.
-
Hi Okay, first off, I would suggest using a php framework. That will make your life much easier. Google "PHP MVC Frameworks". Read up on it as much as possible. With a framework you basically can divide your website into sections and load them independantly and update content accordingly. To answer your question, you can make it work the way you want, although just because you can do it that way, doesn't mean you should and that it is the right way, because it is not. Using a framework would be the right way. This part of your code: //Check to see if being redirected from the index page to itself e.g. index.php?body=./inc/body.inc.php If that is the url that you pass to change the body content, it won't work because you have '/' in your url. A '/' gets interpreted in the url as part of it. You need to urlencode it. Check out: http://php.net/manual/en/function.urlencode.php This part: if ($_POST['body']=="") Is also wrong. If the 'body' you are referring to is the part sent through the url, then you need to use $_GET instead of $_POST. But just remember to urldecode your $_GET value before using it.
-
Download this: http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js Then use this code: <script type="text/javascript" src="jquery-1.3.2.js"></script> <div id="fadeout">Hello World</div> <script> window.setTimeout(function() { $('#fadeout').hide(2000); }, 15000); </script>
-
Get elements values by ID and join them in a hidden input.
Tazz replied to Repgahroll's topic in Javascript Help
Try this: <input type="hidden" name="hidden" id="hidden"> <input type="text" value="hello" id="one"> <input type="text" value="world" id="two"> <script> function concatenate() { string = document.getElementById('one').value + ' ' + document.getElementById('two').value; document.getElementById('hidden').value = string; } </script> -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
Im with syed on this one, lets try this rather: <div id="nothing"> <a href="www.nothing.com?tab=3"></a></div> Note the the ?tab=3 added to the and of the URL and then on the page where you display the thumbnails: <div class="<?php if ($_GET['tab']==3){ echo "active"; }?>"></div> I like to use shorthand if notation let me show you how : <div class="<?php echo ($_GET['tab']==3 ? 'active' : '')?>"></div> Both should work, just personal preference which way you choose. -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
Have you already written that javascript function that sets your active/default tab? Does it take a paramater which is the ID of the tab? Then it's simple. You have the js: <script> function setTabs(tabID) { //set my tab here } </script> And the thumbnail: <div id="nothing" onclick="setTabs('nothing')"> <a href="www.nothing.com"></a></div> -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
Hey adredz I dont know for a fact if your code will work. But what I would suggest trying is : <div id="nothing" onclick="<?php $_SESSION['tab']='3'; ?>"> <a href="www.nothing.com"></a></div> Remove the echo in the onclick event. Also, have you started the session on that specific page? Just add this above your code session_start(); You have to insert that on every page you intend to access session variables. -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
My point is, why store a variable in a Session, when you can just pass it to wherever you need it, and solve your problem. -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
If I understand you correctly, you have a list of thumbnails representing pages on your website. Once clicked, you want the tab to remain highlighted/selected/whatever? The most optimal way to do it would obviously depend on the framework you are using. Say you are using an MVC framework and have defined three view files. Header, body and footer. Your thumbnail will have an href pointing to the controller of ther file eg. You'll obviously have a few of these: <a href="www.example.com/bla"><img src="NOT_SELECTED.jpg"/></a> Ok, so you have a controller named "bla". This controller will process any data and send it to the Views. Controller "bla" will pass an extra variable named $selected_page to your header file. In this case tthe value of $selected_page will be "bla" So now your header page will have the following layout for the thumbnails: <a href="www.example.com/bla"><img src="<?php ($selected_page == 'bla' ? 'SELECTED.jpg' : 'NOT_SELECTED.jpg') ?>"/></a> Sessions are there to store session specific info, such as username, or id. You can obviously use it for whatever you want, but programmers sometime forget to unset them after use or they get lost when the session times out. Rather take the safe route. http://www.sqlmag.com/Articles/Print.cfm?ArticleID=49114 -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
Using Sessions for keeping track of what page you're on isn't the most optimal way to it, but I guess it will work. -
Call javascript function and redirection as onclick values of div?
Tazz replied to adredz's topic in PHP Coding Help
adredz, what exactly are you trying to do? It sounds like you are trying to post values from one page to another, you can do this by either using an html form posting to a php page or if you really want to use javascript and you do not want the page to redirect, you can use Ajax. -
Workaround found: login page view : <form action="<?php echo BASEPATH; ?>post.php" method="post"> ID number <input type="text" name="id"><br/> Password : <input type="password" name="password"><br/> <input type="hidden" value="login" name="returnPage"> <input type="submit" value="Login" /> </form> post.php page : <?php session_start(); if(isset($_SESSION[$_POST['returnPage']])) { unset ($_SESSION[$_POST['returnPage']]); } else { foreach($_POST as $key => $value) { //sanitizing post! $post_array[$key] = strip_tags($value); } $_SESSION[$_POST['returnPage']] = serialize($post_array); } header("location:".$_POST['returnPage']); ?> and inside my login controller : session_start(); if(isset($_SESSION['login'])) { $login_details = unserialize($_SESSION['login']); } Not the best way to do it, getting some sort of url rewriting going on the server would be best. But under the circumstances this is the best way I think.
-
Hi thorpe, thanks for your reply. That is really awesome, I didnt know you can do url rewriting with IIS7. I tried checking our IIS version but it doesnt display it. We're running Win Server 2003 R2 with service pack2 on our server. All I know is that its definately not IIS7 that we're running and like I know this company by now, they wont bother listening to my cries for upgrading. What I am thinking of doing now, which is probably the easiest way out of this dilemma, is to build a post.php file. Esentially a file that is used just to post forms to, it will loop through the $_POST and put the values in a Session and I will post an additional variable with the name of the controller to which it must redirect the page after the post has been saved in a session.
-
I have thought of grabbing the POST in the 404 page and passing it on to the controller, problem is that the POST is already null by time I get to the 404 page. On my dev PC I run XAMPP to host my PHP projects in. So I have my code structure in a folder with the 404 page in the root directory with a .htaccess file which contains : ErrorDocument 404 /404.php. This redirects the Not Found page to my 404 page. So I wonder if my POST doesn't get lost inside the .htaccess file? On our live server you set the 404 page in IIS settings which means the 404 page will be the first point of entry for any pages not found. Do you think the POST would be available in the 404 page on our live server? I suppose the only real way to found out would be to test it.
-
Thanks for the reply simshaun. Your first option sounds interesting. Forwarding the post data through headers. Can you perhaps give me a link to a website explaining it a bit more in-depth?
-
The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rewrite. I recently wrote a custom framewok that is loosely based on Codeigniter. To get SEF URL's 'n used a custom 404 page to redirect my URL's to where they should be. An example URL would be www.example.com/search. 'Search' would not be found and the script would go to the 404 page which would then redirect to my controller named search.php which in turn would load the necessary models and finally the views. This all works perfectly. My problem however is when I use a simple html form that posts to a php file. The action is set as follows action="<php echo $BASEPATH ?>search" this path resolves to the search controller. But the big problem is this file does not exist. So I do get directed to the page, but the $_POST is empty. Does anyone have any ideas on how to get around this? The other option is to just avoid forms alltogether and use AJAX for everything, but there has to be something that I am missing or can do different.