Java Script and PHP Issue
I am using a JS date picker and it works great all by itself. However when I link it to a MySQL db the JS no longer works. Here is my source code below any help would be appreciated.
Thanks
Joe
<?php require_once('Connections/Runin_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `time` (`Time 1`, `Time 2`) VALUES (%s, %s)",
GetSQLValueString($_POST['Time_1'], "text"),
GetSQLValueString($_POST['Time_2'], "text"));
mysql_select_db($database_Runin_db, $Runin_db);
$Result1 = mysql_query($insertSQL, $Runin_db) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Time 1:</td>
<td><input name="Time 1" type="text" id="Time 1" value="" />
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp" /></a></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Time 2:</td>
<td><input name="Time 2" type="text" id="Time 2" value="" />
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp" /></a></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
I would like to know how to do this process. I would like my students to complete the module and then enter there name in the certificate line. Then have them enter their email address so that the certificate can be emailed to them and they can print it off. I would like to have the certificate be a PDF file so they cannot alter the name of the person who took the course.
Similar Messages
-
Hello to everyone.
When encoding with PHP using sha1 i do not get the same result as Java's sha1 encoding.
For example encoding letter 'e' in PHP produces:
58e6b3a414a1e0[b]90dfc6029add0f3555ccba127f
whereas in Java it produces:
58e6b3a414a1e0[b]3fdfc6029add0f3555ccba127f
Below is the code i am using for both Java and PHP
String password=pass;
java.security.MessageDigest d =null;
try {
d = java.security.MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
d.reset();
d.update(password.getBytes());
String secret = new String (d.digest());
secret.getBytes();
StringBuffer sb = new StringBuffer(secret.getBytes().length * 2);
for (int i = 0; i < secret.getBytes().length; i++) {
int b = secret.getBytes() & 0xFF;
sb.append(HEX_DIGITS.charAt(b >>> 4)).append(HEX_DIGITS.charAt(b & 0xF));
return sb.toString();
PHP Code:
$str = 'e';
$str2=sha1($str2);
echo $str2;Anyone had similar problems and found a solution to them? I cannot see any mistake in the code so any help would be much appreciated.
P.S: I am running Java 1.4 and PHP 5.1.6 configuration
Kind Regards
ChristophorosHi,
I found your reply regarding "Java sha1 and PHP sha1" on the forum and would like to ask another related question.
I use the following statement to insert username/password to the database:
INSERT INTO [db_Report].[dbo].[tblLogin]
([USERNAME]
,[PASSWORD])
VALUES
('test'
,HashBytes('MD5', 'password'))
GO
In my Java code, however, the following method always return false. I noticed that in the database
HashBytes('MD5', 'password') returns "0x5F4DCC3B5AA765D61D8327DEB882CF99"
while
The the encrypted login password is "[B@13d93f4" in the Java code.
In this case, how should I check the password, using MessageDigest or not ?
Many thanks.
===============
{code}private static boolean authenticateUser(String username, String loginPassword){
boolean authenticate = false;
Connection con = getDatabaseConnection();
if (con != null){
StringBuffer select = new StringBuffer("");
select.append("SELECT password from [db_MobileDetectorReport].[dbo].[tblUserLogin] where username = '"+username+"'");
String strSelect = select.toString();
try {
PreparedStatement ps=con.prepareStatement(strSelect, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
ResultSet rsResult = ps.executeQuery();
byte[] passBytes = loginPassword.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] encryptedLoginPWD = md.digest(passBytes);
System.out.println("encryptedLoginPWD="+encryptedLoginPWD.toString());
if (rsResult.next()) {
byte[] databasePWD=rsResult.getBytes(1);
authenticate=MessageDigest.isEqual(encryptedLoginPWD,databasePWD);
} catch (Exception e) {
//TBD
} else {
//TBD
return authenticate;
}{code}
Edited by: happy_coding on Dec 21, 2009 1:39 PM{code}{code}
Edited by: happy_coding on Dec 21, 2009 1:40 PM -
What're the differences between JSP, Java Script, and Java Applet?
I am confused by the concepts: JSP (Java Server Page), Java Script, and Java Applet? What are their main differences?
I don't know about differences, but one of their main similarities is that each of them has a page in Wikipedia.
JSP
JavaScript
[Java applet|http://en.wikipedia.org/wiki/Java_applet]
There. That should give you enough information. -
Problem in merging java script and java code
hi,
i want to merge java and javascript code but it is giving some surprising results.
this is my code:
<script language = "javascript">
<%
String query_result= "1";
String buttontype="";
buttontype=(String)session.getAttribute("buttontype");
query_result = (String) session.getAttribute("query_result");
out.println(query_result);
if(buttontype!=null&&(buttontype.equals("submit")))
out.println(buttontype);
%>
alert(<%=ka%>)
</script>
<%
%>
now if i'll move "<script language = "javascript">" to:
<%
String query_result= "1";
String buttontype="";
buttontype=(String)session.getAttribute("buttontype");
query_result = (String) session.getAttribute("query_result");
out.println(query_result);*/
if(buttontype!=null&&(buttontype.equals("submit")))
out.println(buttontype);
%>
<script language = "javascript">
alert(<%=query_result%>)
</script>
<%
%>
then it prints correctly and gives alert "1" but if i'll change query_result="manish" then it is not giving alert also
i don't know wht is happening
plz help me out
manishhi pgeuen,
Thanx for ur reply
now its working i have changed my jsp exp. tag to
alert("\"<%=ka%>\"")
and it is displaying correctly.
and if i'll give the scripting tags in "if block"then it will work but till now i didn't get why i was not getting any output when the scripting tags covers the whole jsp code. i think we can mix java script and jsp in any way.
well thanx a lot.
manish -
What is java script and how do I enable it?
What is java script and how do I enable it
JavaScript is enabled by default for Adobe Reader for iOS, and I don't see that there's a way to disable it. It is currently used within a document to control the behavior of form fields, such as automatic formatting and calculations. Only a small subset of what's available in the desktop version is available in the mobile versions.
-
for months I have checked the forums, and seen the same issues with Adobe Flash Player ... I have uninstalled and reinstalled too many times now and am totally frustrated with Firefox,. I just get it working again and Firefox updates and then I have the same issues ... and now my java script is screwing up and it never did before .... this all came after the latest update .... is anyone else having these issues or is my operating system under attack???
Recent crashes of certain multimedia contents (this includes Youtube videos, certain flash games and other applications) in conjunction with Firefox are most probably caused by a recent Flash 11.3 update and/or a malfunctioning Real Player browser plugin.
In order to remedy the problem, please perform the steps mentioned in these Knowledge Base articles:
[[Flash Plugin - Keep it up to date and troubleshoot problems]]
[[Flash 11.3 crashes]]
[[Flash 11.3 doesn't load video in Firefox]]
Other, more technical information about these issues can be found under these Links:
http://forums.adobe.com/thread/1018071?tstart=0
http://blogs.adobe.com/asset/2012/06/inside-flash-player-protected-mode-for-firefox.html
Please tell us if this helped! -
Doubleclick, banners, java script and K size
I've been making flash banners for 10 years and now am trying (unsuccessfully) make banners with adobe edge. The reason I say unsuccessfully is because of the 100k javascript files that are associated with the project. Anyone who makes banners 300x250, 728x90, 300x600, etc.... knows that the typical k size is 30-50 kilobytes. this isn't possible with the k size the java script ads to the project.
Doubleclick studio wont let the dns files be hosted.
Now I'm wondering if this is an antiquated method of gauging the effect a banner has on a website. My question is, should java script count towards the final K size of a banner? isnt it typically loading images that the publishers are concerned with?
Does a 100k java script file take up the same bandwidth of loading an image onto the site? I'm not sure how I could convince such large entities to change how they view the spec sheet but if as i suspect java script shouldn't be lumped into the same category as images then maybe I can convince someone to change the required specs and split it into "images" and "java script" kilobyte sizes.
chad demossI kind of doubt that it is in JRE issue, since Java and Javascript have not much to do with each other.
-
Hi,
I have got a .jsp page wherein there is a 2 dimentional string array defined within a scriplet.
I have defined an other function in java script within the same page.
Now I need to access the string array within the java script. Can someone please hep me how to achive this...
I tried something like this, but its not working:
function displayNameIndex()
var source = <%= imgArrayName %>[0][0];
where imgArrayName is the name of the String array in the scriplet code.
Many thanksJSP is executed at the serverside and generates a long HTML string. Javascript is part of this HTML string. Once this string is arrived at the client, the JS will/can be executed.
What you're expecting here is that the Javascript is able to access the Java Object which is converted into a simple plain vanilla string. That is not true. Better is to put all of this logic in the server side or in the client side. You may need to iterate through the Java String[][] object and print all values into the response, so that JS can access them. -
Any body can give a sample program how can i included a java script in a servlet program
Regards
MarimuthuWhat exactly are you trying to achieve?
This is a typical servlet with raw html. You can also put javascript there the same way html is there.
public class FirstServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
java.io.IOException {
//set the MIME type of the response, "text/html"
response.setContentType("text/html");
//use a PrintWriter to send text data to the client who has requested the
//servlet
java.io.PrintWriter out = response.getWriter( );
//Begin assembling the HTML content
out.println("<html><head>");
out.println("<script language='javascript'>alert('Hello Muthu');</script");
out.println("<title>Help Page</title></head><body>");
out.println("<h2>Please submit your information</h2>");
//make sure method="post" so that the servlet service method
//calls doPost in the response to this form submit
out.println(
"<form method=\"post\" action =\"" + request.getContextPath( ) +
"/firstservlet\" >");
out.println("<table border=\"0\"><tr><td valign=\"top\">");
out.println("Your first name: </td> <td valign=\"top\">");
out.println("<input type=\"text\" name=\"firstname\" size=\"20\">");
out.println("</td></tr><tr><td valign=\"top\">");
out.println("Your last name: </td> <td valign=\"top\">");
out.println("<input type=\"text\" name=\"lastname\" size=\"20\">");
out.println("</td></tr><tr><td valign=\"top\">");
out.println("Your email: </td> <td valign=\"top\">");
out.println("<input type=\"text\" name=\"email\" size=\"20\">");
out.println("</td></tr><tr><td valign=\"top\">");
out.println("<input type=\"submit\" value=\"Submit Info\"></td></tr>");
out.println("</table></form>");
out.println("</body></html>");
}//doGet
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
java.io.IOException {
//display the parameter names and values
Enumeration paramNames = request.getParameterNames( );
String parName;//this will hold the name of the parameter
boolean emptyEnum = false;
if (! paramNames.hasMoreElements( ))
emptyEnum = true;
//set the MIME type of the response, "text/html"
response.setContentType("text/html");
//use a PrintWriter to send text data to the client
java.io.PrintWriter out = response.getWriter( );
//Begin assembling the HTML content
out.println("<html><head>");
out.println("<title>Submitted Parameters</title></head><body>");
if (emptyEnum){
out.println(
"<h2>Sorry, the request does not contain any parameters</h2>");
} else {
out.println(
"<h2>Here are the submitted parameter values</h2>");
while(paramNames.hasMoreElements( )){
parName = (String) paramNames.nextElement( );
out.println(
"<strong>" + parName + "</strong> : " +
request.getParameter(parName));
out.println("<br />");
}//while
out.println("</body></html>");
}// doPost
} -
Java(script) and WD4A
Hi all,
I know you can't use any javascript in WD yourself, but after creating a WD component / application, the code that is generated, does it contain, beside HTML code any java(script) or some other kind of scripting?
If so, what kind of scripting should I think of and what does it do?
Kind regards,
Micky.>
Micky Oestreich wrote:
> Thanks for the quick reply (even on a sunday). Just for my understanding: The fact that you cannot enter your own javascript like in BSP, lies in the fact that SAP wants to make WD platform independent, correct me if I'm wrong? So how does SAP ensure this by using javascripting when generating the WD webpages? Doesn't this make it platform dependant?
We aren't just shooting for independence between browsers (IE vs. Firefox) but entire clients. In Web Dynpro you will soon be able to run the same application in a Browser or the Flex Client or the NetWeaver Business Client without changing anything in your application - the later two don't even use JavaScript or HTML.
Now how do we ensure cross-browser support in JavaScript - well nothing really special there. Sometimes it takes separate JavaScript libraries and sometimes it just takes branching logic within a JavaScript function. Most of the differences between the browsers are pretty well documented and although a pain to deal with not really that much of an unknown. Still better to let one small group of UI foundation developers have to deal with than all the thousands of application developers. -
Java script and password request
Hi, this is my husband's play book and he is having a couple of problelms with it at the moment..
1.First:
When he tries to load a paticular app, he gets a java script error "null" message..I loaded the same app on my phone (Galaxy S III) and it worked fine but it doesn't on my DH's or my DIL's BB Playbook..
2. Password Request:
While reading his ebooks,BB playbook keeps asking for him to supply his password again..he "save"s it each tie and then it asks him again a few minutes later..same happens if he selects "cancel"which means??
so who's problem is it that it doesn't work?? Blackberry or The Citizen Developer?? this only started all of a sudden..up till just recently, there was no problem with this app..and deleting it and reinstalling it doesn't help.. -
I use SAP Infoview for work. To modify reports it requires a Java script to run. I had it set up in the previous version of ff to always allow from this specific site and it worked wonderfully. Now, in the new version, despite following all of the instructions from others, I cannot do my work because I cannot run Java script. I can still run it in Safari, but Safari is a last resort for me to use. I prefer Firefox and have all of my links stored there.
Some sites are not fully compatible with Firefox 4's new HTML5 rendering engine. Can you turn that off and test without it? Here are the steps:
(1) Open a new tab, then type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
(2) In the filter box, type or paste '''html5''' and pause while the list is filtered
(3) Double-click '''html5.parser.enable''' to toggle it to false (it should turn bold).
Then change back to the SAP tab and reload the page.
Does that make any difference? -
Hello,
I have a JSF component like this that has a pageSize attribute. It shows a grid with 5 elements.
<x:gridView id="#{tab}GridView" pageSize="5">
</f:gridView>Then I have a drop down with 5 menu items where the user can select how many elements they want to see visible on the grid. My question is, how do i use Java Script to to change the pageSize attribute above with what the user selected in the menu below? I have been looking at java script code and online docs for an hour and cant come up with anything that seems to work. Any help will be appriciated. Thank you!!!
<x:selectOneMenu id="myMenu" onclick="">
<f:selectItem id="perPage1" itemValue="1" itemLabel="1" />
<f:selectItem id="perPage2" itemValue="2" itemLabel="2" />
<f:selectItem id="perPage3" itemValue="3" itemLabel="3" />
<f:selectItem id="perPage4" itemValue="4" itemLabel="4" />
<f:selectItem id="perPage5" itemValue="5" itemLabel="5" />
</x:selectOneMenu>[...]how it was never designed to be used for
such large applications[...]All I can say is that if this is true, then it doesn't show. Yes, I know it (oak) was originally designed for embedded systems, but Java and Oak aren't identical.
My assembly teacher
always makes fun of Java, saying java gives you far
less control, it prevents you from making mistakes.
No control over unsigned/ signed values, pointers
etc. Yes. But broadly speaking that's the point. Java sacrifices control over such things. The return, however, is that programmers are able to be more productive because of the great swathes of problems that can no longer arise.
The mistake is in assuming that Java is the best tool for everything. It isn't, and in fact no language us. As it turns out, Java is just great for building enterprise systems. It has a few other strengths, some of which (applets for example) have been more important in its original uptake but are now relatively minor features.
You don't write an enterprise website in Intel assembly, and you don't write device drivers in Java.
Not saying its not good but its good for
smaller applications like cell phones and
mini-computers.I think you mean something different by mini-computers to what I mean...
Its portability is actually the main point in its favour for use in cell phones. If it weren't for that, I think C or C++ would probably have sole ownership of that space.
Now i'm not saying any thing against it just
confused on why a class like data-structures at my
University [...] would be taught using java when C would
probably be a lot better for Very Large ADTS.You and Joel Spolsky:
http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html
I disagree, because I don't think it much matters what language you learn - experience trumps any particular initial language choice. If you're still using Java in 15 years I'll be fairly surprised. -
Java Script in Templates issue
I have created a help system for our new financial reporting
system and a developer has created a template which includes Java
scripted 'Rate this page' radio buttons and a comments field in the
header. I have imported the template into my project and attached
all the topics to this template. When I preview or regenerate/view
the HTML output and click on the comments field an error is
returned.
Our developer can get this to work on his machine but not
mine (I.E security setting have been set to low but it still wont
work).
When I generate on the developers machine, we get our Java
script code in the headers but not when we generate on my machine.Sorry - v rude of me:
Any help/suggestions would be gratefully considered -
Java Script: Form Submit issue.
Is there a way where I can submit two forms ?
Thats is submit 2nd form only when the first form is submitted.
I tried this it works.
function formSubmit(){
document.form1.submit(); //Submit First Form
alert(); //This will stall the execution thus form2 will not be submitted till I click on OK
document.form2.submit();
}But If I dont put an alert in between, only the second form is submitted.
If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the action event triggered due to first form submit.
Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??Relax people... Ok I will move my querries else where :) ..
But whats wrong if somebody can provide me an answer ? I am sure most of you know java script , if you dont know then don't answer simple as that.
You do know that Sun did not create JavaScript, right? So the Sun forum sites may not be the best place to look for a JavaScript forum " {code}
You mean to say if something is not from sun I am not supposed to ask a question on that, I agree that this is JAVA Programming forum.
Peace,.
Maybe you are looking for
-
'Reopen All Windows From Last Session' Will Not Work
So, first Safari won't let me even open a new window and told me that I needed to reinstall and that my version of Safari was missing something - I can't remember the precise thing it told me I was missing. At that point, I restarted to see if that w
-
B2B/SOA 11.1.1.6.0 We are setting a new trading partner and when we started document transmissions we are getting errors on the inbound messages: B2B-50037: B2B inbound message processing error. The attachment shows the relevant lines from the soa l
-
Third-party plug-ins intermittently working with CS 5
Hi folks, Hang in there with me, folks… I'm going to attempt to ask a coherent tech question (or several)! Gulp. So here it is: I'm working on a Mac OS X Lion (10.7.5) with Photoshop CS 5. As part of my photo editing workflow, I used several plug-ins
-
Unable to upload PM Work Order Header Status
Hi, I have made LSMW for tcode: IW31. I have a requirement to upload legacy data to SAP with their existing header status. For instance: I have a work order which got a header status complete and I want to upload this work order with its status. So,
-
Remove particular field and button from a screen when using pnp
hi, i came to a request of remove a field and button from the displayed screen. i developed the report using logical database pnp. i need help.