•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,652 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,121 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 10933 | Replies: 3
•
•
Join Date: Jan 2005
Posts: 20
Reputation:
Rep Power: 4
Solved Threads: 0
Hi,
i was wondering if anyone can help me. i am new to php and was wondering if it was possible to embed javascript in php. i was trying to get an alert/msg box up to explain an error to the user.
i have written the following code
<?php
.............
/* CHECK IF EMAIL ADDRESS SUBMITTED IS VALID */
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $UNameFrm))
{
<script type = "text/javascript">
alert('Congrats');
</script>
exit();
}
/* CHECK IF EMAIL ADDRESS ALREADY EXISTS IN THE DATABASE */
$check = mysql_query("select * from acctbl where Username = '$UNameFrm'");
$result = mysql_query($check);
$num = mysql_num_rows($check);
if ($num > 0)
{
echo "This email address already exists";
exit();
}
else
{
$insert = ......
}
?>
can anybody help me? if this can't be done with javascript can anybody tell me how to do it another way.
Thanks in Advanced,
Scoobie.
i was wondering if anyone can help me. i am new to php and was wondering if it was possible to embed javascript in php. i was trying to get an alert/msg box up to explain an error to the user.
i have written the following code
<?php
.............
/* CHECK IF EMAIL ADDRESS SUBMITTED IS VALID */
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $UNameFrm))
{
<script type = "text/javascript">
alert('Congrats');
</script>
exit();
}
/* CHECK IF EMAIL ADDRESS ALREADY EXISTS IN THE DATABASE */
$check = mysql_query("select * from acctbl where Username = '$UNameFrm'");
$result = mysql_query($check);
$num = mysql_num_rows($check);
if ($num > 0)
{
echo "This email address already exists";
exit();
}
else
{
$insert = ......
}
?>
can anybody help me? if this can't be done with javascript can anybody tell me how to do it another way.
Thanks in Advanced,
Scoobie.
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- FireFox config setting through Java Script (Community Introductions)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- A question on java script?(Please answer ASAP) (Java)
- java script for main menu (ASP)
Other Threads in the PHP Forum
- Previous Thread: This ought to be simple - extra spaces
- Next Thread: Parsing variabls to texbox



Threaded Mode