Jump to content

Javascript in php


jon4433

Recommended Posts

I have some if statements in my php code, and I would like to have javascript so that I can have pop up boxes with the error on. I have been trying to work it out, but i'm getting 2 errors.

 

It's my first time using javascript today, so I have no idea if it is correct or not.

 

My javascript and php if statement is giving me one error.

<script type="text/javascript">
if(empty($username))
{
	function show_alert()
	{
	alert("Please fill in the username field!");
	}
}
        </script>

 

And i'm also getting another error with the 'style type'.

<style type="text/css">
body {
font-family: Minecraft;
background-image: url(images/background.png);
background-size:100% 100%;
background-attachment: fixed;
background-repeat: repeat-x;
background-position: left top;
background-color: #999999; 
}
body,td,th {
color: #FFF;
}
</style>

Link to comment
Share on other sites

That still doesn't change the fact that JavaScript and PHP are tow different languages that run in two completely different contexts. JavaScript executes client side within a browser, PHP executes server side within the server. Your code makes no sense because it attempts to mix the two together.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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