开发者

Temporarily modifying CSS of an HTML page using PHP script

I am working on a website where a user types in a domain name and the html page goes into a php page to check it's availability. The page needs to go to the next html page if the domain is available but if the domain is taken, it needs to return to the first html page and modify the css to reveal a piece of hidden HTML code displaying that the url is开发者_StackOverflow中文版 taken.

What kind of php code do I need to add to my php file, so that when the script come up with a false (domain is taken) it will shoot the browser to the form.html and change the css to display the html div tag that was originally hidden without making the change permanent.

Also, if there is an better way to change the page without touching the css and html (ie. jQuery), then please let me know.

I am a complete noob when it comes to php so I don't even know how to search for this. Sorry if this question has not been answered but I did not even know how to search for this and when I google'ed the title I got nothing close to what I was searching.

Thanks!


On the page that check's the domain's eligibility, you would have something along the lines of this:

<?php
$domaintocheck = $_POST['domain'];
$isavailable = checkifavailable($domaintocheck);
if ($isavailable) {
   header("Location: nexthtmlpage.html");
} else {
   header("Location: firstpage.html?domain=taken");
}

And then on the FIRST PAGE near your text field that the user enters in their domain, you add something like

<?php 
if ($_GET['domain'] == "taken") {
  echo "<span class='red'>Sorry, that domain is taken. Please enter another. </span>";
}
?>


First of all this could be done with PHP but if I understood you correctly, you could fo what you want using the if statement in PHP, but remember PHP is server side and this will be an excess (or unnecessary load on the server).

It would go SOMETHING like this:

if ( page does not exist ){
  echo '<link rel="stylesheet" type="text/css" href="style.css" />';
}else{
echo '<link rel="stylesheet" type="text/css" href="style.css" />';
}

You of course could do some inline modifications too.

With jQuery or javascript (you could do that client side), you can check for whatever you want too using (jQuery):

if( condition ) {
    // do something
}

jQuery is very powerful modifying CSS. Just start by reading the basic tutorials or any other...

I hope this answers your question!! good luck! please tell me if you need any clarification!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜