FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Javascript vs asp/php





Manofgames
ive just started redesigning my site and instead of using php / asp.net i've gone for javascript.

Really limited but good for simple stuff like changing page content based on a string in the address (think that's what its called). It also allows me to do the cookie thing where you can place a cookie on the users computer to see how many times they've been to your site.

And google now offer a free service where you put a code from them in your site(javascript) and they give free statistics on your site.


I know that i said javascript vs asp/php what im tryuing to get across is that for simple stuff when you start programming you can use things like javascript to get some really cool results
ninjakannon
You can do all that stuff you talk about doing with javascript with php. And if you had php web pages you can always insert some html containing javascript in the middle (just close off the php tag, open html one, then close the html when you've done your html coding and open some more php, something like this:
Code:
<?php
echo "This is my first line of text\n";
?>
<html>
<script type="text/javascript">
document.write('This is my second line of text' + "\n");
</script>
</html>
<?php
echo "This is my third line of text";
?>
)
But I've never used ASP, so I can't tell you anything about that.

EDIT: By the way, I'm not sure if this code is all correct, as I just wrote it quickly. But you get the idea.
Marston
Comparing Javascript to ASP or PHP is like comparing apples and oranges, really. Javascript is a client-side scripting langauge which cannot interact with databases, while ASP and PHP are both Server-Side scripting languages which (among many other things) CAN interact with databases.
coreymanshack
I've heard that there is javascript that CAN accsess database (although rumored) I never have found out how...
Marston
coreymanshack wrote:
I've heard that there is javascript that CAN accsess database (although rumored) I never have found out how...
I doubt that's true. A client-side script accessing a server-side database would be a horrendous security risk. Sad
coreymanshack
that's true, i've never thought of that. They could just go to view source and see all of the database passwords and everything!
ninjakannon
coreymanshack wrote:
that's true, i've never thought of that. They could just go to view source and see all of the database passwords and everything!

Unless you loaded them in from somewhere. But, the user would obviously still be able to get the name of the file you send to, and the variables you send it / try to recieve. So you'd have to have a heck load of security server-side to protect it, but nothing is un-hackable. And doing that would kinda defeat the object of having a client-side script in the first place - not to mention making it way less secure. Confused
mathiaus
Using javascript for dynamic content? If they don't have javascript they won't get any content at all though! Javascript is better for optional things which are added extras rather than core 'needs to work' stuff.
Leptitpoucet
Does anyone now how to avoid using Php to send a email?

I prefere to use something else.

By the way the "mailto" fonction doesn't work very well.
ninjakannon
I don't know any other way (but you can use asp and there must be more ways, I'm sure), but why don't you want to use php? Just use the mail function, which works fine for me.
Arno v. Lumig
You shouldn't use mailto, but mail().

Code:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>



Is the way you send a mail to someone. I guess the code is self-explanatory...


Greetz, Eddy
Leptitpoucet
Arno v. Lumig wrote:
You shouldn't use mailto, but mail().

Code:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>



Is the way you send a mail to someone. I guess the code is self-explanatory...


Greetz, Eddy


Thank you for your Help, I'm using know mail() php fonction
But I still have a problem:

Quote:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\allachats\contactsa.php on line 103


Do you know how to solve this?
ninjakannon
Slight change:
Code:

<?php
$to = "my@email.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "anything@anythingelse.com";
$headers = "From: $from";
$sendMail = mail($to,$subject,$message,$headers);
if ($sendMail) {
echo "Mail Sent.";
} else {
echo "Mail NOT Sent.";
}
?>


Quote:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\allachats\contactsa.php on line 103

I'm guessing that you're running this from your PC. You need to do what it says, change a few settings in your php.ini file. You need to change the settings that are relevant to emailing, SMPT and smtp_port, in this case. But I'm sure there are other things you may need to change in there for use of other functions.

Yes, unfortunatly, there is a bit of setting up to do with PHP, you can't just run it like magic. Wink
Related topics
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.