php or javascript?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shadow_blade47
Forum Newbie
Posts: 12
Joined: Fri Nov 07, 2003 3:41 am

php or javascript?

Post by shadow_blade47 »

hi there, I'm looking into various ways of validating a inputted e-mail address in a form. Should I use javascript or php to check things like whether it contains an '@' smybol? I was told javascript would do it faster, is this true? thanks,
james
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

javascript will prevent the user from having to submit the page and the php script running then passing it back to the browser, because it doesnt have a valid email address, so yes it will be faster. However, you will still need to do some checking in the php script as users may have turned off javascript.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

For this task JavaScript would work well as it is done on the client side and would allow instant validation. PHP would have to be submitted in order to validate. Both would work but JS is certainly the way to go in my opinnion.


John M
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Always remember that Javascript can be turned off - use JS validation to avoid repeated calls to the server, but always make sure you check stuff server side as well. Never trust your users.

Mac
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

Post by mesz »

I came to the site ready to ask a question about php to javascript and here is the thread!

Code: Select all

function maak_code()
{
  var raam = window.open('','vmlcode','height=600,width=600');
  raam.document.open();

  with(raam.document){
  write('<html>\n');
  write('<head>\n<title>VML code</title>\n</head>\n');
  write('<body bgcolor="buttonface">\n');
  write('<center>\n<form>\n');
  write('<textarea style="width: 500px; height: 500px;">\n');

  write('<html>\n<head>\n\n');
  write('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>\n');
  write('<style type="text/css">\nv\\:* &#123; behavior: url(#default#VML);&#125;\n</style>\n\n');
  write('</head>\n<body>\n\n');
  write(document.frames&#1111;0].document.body.innerHTML.replace(/<br>/gi, '\n'));
  write('\n\n</body>\n</html>\n');

  write('</textarea>\n<br>\n');
  write('<input type="button" value="Select" style="font-family: Verdana, Arial; font-size: 12px; width: 150px; margin-top: 8px;" onclick="document.forms&#1111;0].elements&#1111;0].select()">\n');
  write('</form>\n</center>\n');
  write('</body>\n');
  write('</html>');
  &#125; 

  raam.document.close();
  raam.focus();
&#125;
How the hell do I capture the VML code that is written to the window as PHP.
PHP is all I know - and not much of that - and so for my users to save the drawings I can only manipulate PHP .

Please, can I have a tip, a direction to help me capture the generated VML code as PHP.

This is not for profit...this is for a community site
unitedartcity
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

BOTH!!
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

Post by mesz »

php_wiz_kid wrote:BOTH!!
What does that mean?
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

Sorry, I didn't read your post, I was responding to the validate post. Sorry again.
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

Post by mesz »

Fair enough, no problem...do you know the answer though, I dont know where to begin... :?
Post Reply