Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS file link is not working on PHP page

Tags:

css

php

I have a Php page the code for which is below, I am trying to apply this signup.css but its not working. In PHP admin I can see the CSS shows up under Styles as SignUp.css, I have just placed this css in my theme directory under my theme as SignUp.css, I have tried "Signup.css" , created a css folder and put this css in there and tried "css/SignUp.css" but that did not work either. Please help . Thanks for your time

<html>
<link href="Styles/Signup.css" media="all" rel="stylesheet" type="text/css"/>

    <head>
        <title>Create</title>
        </head>
<body>

<?php

if($_POST['action']=='create'){
    //include database configuration
    $dbhost = "localhost";
     $dbuser = "abc";
     $dbpass = "xyz";
     $dbname = "test";

     $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
     mysql_select_db($dbname) or die ('Unable to select database!');


    //sql insert statement
    $sql="insert into user ( firstname, lastname, username, Email, password )
            values ('{$_POST['firstname']}','{$_POST['lastname']}','{$_POST['Email']}','{$_POST['username']}','{$_POST['password']}')"; 

    //insert query to the database
    if(mysql_query($sql)){
        //if successful query
        echo "New record was saved.";
    }else{
        //if query failed
        die($sql.">>".mysql_error());
    }
}
?>

<!--we have our html form here where user information will be entered-->
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="index.html">
<h1>Sign-up form</h1>


<label>Name
<span class="small"></span>
</label>
<input type="text" name="name" id="name" />

<label>Email
<span class="small"></span>
</label>
<input type="text" name="email" id="email" />

<label>Password
<span class="small">Min. size 6 chars</span>
</label>
<input type="text" name="password" id="password" />

<button type="submit">Sign-up</button>
<div class="spacer"></div>

</form>
</div>

</body>
</html>
like image 426
arun thakur Avatar asked Dec 04 '22 18:12

arun thakur


2 Answers

From you comments on existing answers, it doesn't look like something we could find out based on the provided code. Here are a couple of things that could help you diagnose the problem though.

In your browser, open up developer tools. (For Firefox, get Firebug and hit F12, For Chrome or Opera, just hit F12 for the built in tools.)

Then you want to open up the network tab ('Net' in Firebug, 'Network' in Chrome)

Once you have that open, reload the page and look at the server requests. One of them will be for your CSS file. What you want to look for is the HTTP status. If that Status is anything starting with a 4, you've got trouble. Either it's a 403 which means you don't have the correct permissions to load the file, or you'll have a 404, as we all know, 'not found', which would indicate that your URL is faulty.


Another way to quickly find out whether the file is actually loading is to view the source of the page in the browser, and click the link to the CSS file. In Firefox, doing that makes the source viewer load the contents of the CSS file instead. If that doesn't work out, you also get an idea that it can't be accessed. It's worth noting that the first method will make it clearer what exactly the issue is though.

Most likely I assume you have a typo in your capitalisation of the file name or path. If it is hosted on a non-windows server, that almost certainly makes a difference.

like image 142
MichD Avatar answered Dec 10 '22 10:12

MichD


The <link> tag should be within your <head> tag, also consider using absolute "/" path rather than relative if you have sub directories.

like image 34
King Friday Avatar answered Dec 10 '22 11:12

King Friday