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
https://forums.phpfreaks.com/topic/257299-javascript-in-php/
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
https://forums.phpfreaks.com/topic/257299-javascript-in-php/#findComment-1318882
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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