How to get the value by GET method from URL Parameter? - url

I have a problem with this script:
<form action="edit.php" method="GET">
<a class="btn btn-default" href="editj.php?id=3">Edit</a>
</form>
in my edit.php file i have:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="pl" lang="pl">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="content-langiage" content="pl" />
<title>Praca inżynierska</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="kontener_glowny">
<?php
include 'topmenu.php';
?>
<div id="kontener">
<?php
$id = $_GET['$id'];
echo $id;
?>
</div>
<div id="stopka">
Stopka
</div>
</div>
</body>
</html>
and my web browser show me error: Notice: Undefined index: $id in M:\xampp\htdocs\apka\edit.php on line 19.
I have no idea how can i get value of my argument which i have in link,
this script should show me id=3.

Simply use $_GET['id'] instead of $_GET['$id']

Related

Passing a parameter to a webhook

Want to pass and retrieve a query string to my twilio webhook.
http://xx.xx.xxx.xx/TwilioWebhookTraffic/TwilioWebHookTraffic.aspx/TrafficCallBack?GCAcctNbr=667118358011603
which returns:
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form method="post" action="./TrafficCallBack?GCAcctNbr=667118358011603" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="4PSLlcjmwjYT0iXthm7eB3EX5v8lZY62GKDxWDdNDuZndwHLxahDzcX2H0NFNQX+2NAe7hPownCNYxJJVZJreGwJpqZ/Cwm3f2EIiLGFQ4c=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CFB6114E" />
<div>
TWILIO TRAFFIC REMINDER WEBHOOK ASPX PAGE</div>
</form>
</body>
</html>
But does not run the webhook code.
if the URL is just:
http://xx.xx.xxx.xx/TwilioWebhookTraffic/TwilioWebHookTraffic.aspx
then the code is run. but, of course I need the query string.

How can I use Bootstrap with struts 2? [duplicate]

This question already has answers here:
Is Boostrap compatible with Struts 2?
(2 answers)
Closed 5 years ago.
I am beginner of struts2 and bootstarp. I can not use bootstrap with my struts2 form . I am using the following Jar:
commons-fileupload-1.2.2.jar
common-io-2.0.1.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
freemaker-2.3.19.jar
javaassist-3.11.0.GA.jar
javax.servlet-api-3.0.1.jar
mysql-connector.jar
ognl-3.0.6.jar
struct2-core-2.3.14.2.jar
xwork-core-2.3.14.2.jar
asm-3.3.1.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
my jsp page is below:
<%# taglib uri="/struts-tags" prefix="s" %>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="./css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
</head>
<body>
<s:form action="loginprocess" cssClass="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<s:textfield name="username" ></s:textfield>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<s:password name="userpass" ></s:password>
</div>
</div>
<s:submit value="login"></s:submit>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
</s:form>
Not registered yet ,Please Sign Up
Sign Up
</body>
</html>
but it gives a horrible output where all elements are broken. Output is below:
output of my project
which extra jar files I need to add to my project? or what more things is require to create form using struts2 and bootstrap? Please help.
Add theme="simple" to all struts elements.
Like :-
<s:form action="loginprocess" cssClass="form-horizontal" theme="simple">

Overloading blocks with dust.js for nested templates

I have a layout called layouts/master.dust
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{+title /}</title>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="wrapper">
<h3>This is the master header</h3>
{+body /}
</div>
</body>
</html>
I then have a template called index.dust:
{>"layouts/master" /}
{<body}
<h1>{#pre type="content" key="greeting"/}</h1>
{/body}
Predictably, that outputs
This is the master header
Hello, Alex!
(when supplied with the relevant json)
My issue is, I'm creating another "nested" or "child" template: layouts/admin.dust that looks like:
{>"layouts/master" /}
<h4>This is an admin header</h4>
{+body /}
and a template adminIndex.dust that uses layouts/admin/dust like this:
{>"layouts/admin" /}
{<body}
<p>This is some stuff for admin</p>
{/body}
My problem, is the output is:
This is the master header
This is some stuff for admin
This is an admin header
This is some stuff for admin
So, my {+body} block is being called twice, and not overridden by my nested template
Is there a way to do that?
Edit
As per my comment, a more 'realistic' example of admin.dust would be:
{>"layouts/master" /}
<h4>This is an admin header</h4>
<div style="float: left; width: 200px;">
<strong>left nav</strong>
<ul>
<li>Link one</li>
<li>Link two</li>
</ul>
</div>
<div style="float: right">
{+ body /}
</div>
Where by in templates that use the admin layout, their body is in a div floated right (for example)
Your {+body} block is being overridden by your {<body} inline partial in your adminIndex.dust template. The contents of an inline partial (in your case <p>This is some stuff for admin</p>) will be inserted wherever a block is found in your template. If you are hoping to have the master header be replaced by the admin header, you would need your templates to look like this:
layouts/master.dust
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{+title /}</title>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="wrapper">
{+header}<h3>This is the master header</h3>{/header}
{+body /}
</div>
</body>
</html>
layouts/admin.dust
{>"layouts/master" /}
{+header}<h4>This is an admin header</h4>{/header}
adminIndex.dust requires no change.
Note: I have added a {+header} block to layouts/master.dust with a default value, and added a {header} inline partial and removed the {+body} block from layouts/admin.dust. This will output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="wrapper">
<h3>This is the admin header</h3>
<p>This is some stuff for admin</p>
</div>
</body>
</html>

JSF2 Rich Faces issue

I am facing very strange issue using JSF2 (apache MyFaces 2 and Rich Faces 4.3)
Below is the xhtml code.
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:head>
</h:head>
<h:body>
<h:form id="form">
<a4j:commandButton immediate="true" value="Check" action="#{bean.someAction}"/>
</h:form>
</h:body>
</html>
When xhtml code is debugged using firebug and any of the rich faces tag is used , i am getting below error in debugger as :
SyntaxError: syntax error # http://localhost:8480/webAppName/javax.faces.resource/jsf.js.faces?ln=javax.faces&stage=Development:1
When <a4j:commandButton> tag is removed and plain jsf tag <h:commandButton> is used error is not thrown.
Also when <a4j:commandButton> is clicked , ReferenceError: RichFaces is not defined error is thrown.
Attaching the generated html code :
1)h:commandButton with f:ajax inside - (it gives ReferenceError: jsf is not defined error when button is clicked)
<?xml version="1.0" encoding="UTF-8"?>
<!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><link rel="stylesheet" media="screen" type="text/css" href="/contextRoot/rfRes/skinning.ecss.faces" />
<script type="text/javascript" src="/contextRoot/javax.faces.resource/jsf.js.faces?ln=javax.faces&stage=Development"><!--
//--></script>
</head>
<body>
<form id="testForm" name="testForm" method="post" action="/contextRoot/pages/testPage.faces" enctype="application/x-www-form-urlencoded">
<input id="testForm:j_id_6" name="testForm:j_id_6" type="submit" value="Test" onclick="jsf.util.chain(document.getElementById('testForm:j_id_6'), event,'jsf.ajax.request(\'testForm:j_id_6\',event,{execute:\'testForm \',render:\'testForm \',\'javax.faces.behavior.event\':\'action\'})'); return false;"/>
<input type="hidden" name="testForm_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="/6XulvXlIjDBkLb43C7I4+TCqUyuTMbk4Xz6pE7XonVsuqaL" />
</form>
<div id="javax_faces_developmentstage_messages"></div>
</body>
</html>
2) a4j:commandButton - (it gives ReferenceError: RichFaces is not defined error when button is clicked)
<?xml version="1.0" encoding="UTF-8"?>
<!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><link rel="stylesheet" media="screen" type="text/css" href="/contextRoot/rfRes/skinning.ecss.faces" />
<script type="text/javascript" src="/contextRoot/javax.faces.resource/jsf.js.faces?ln=javax.faces&stage=Development"><!--
//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/jquery.js.faces"><!--
//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/richfaces.js.faces"><!--
//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/richfaces-queue.js.faces"><!--
//--></script></head>
<body><form id="testForm" name="testForm" method="post" action="/contextRoot/pages/testPage.faces" enctype="application/x-www-form-urlencoded">
<input id="testForm:j_id_6" name="testForm:j_id_6" onclick="RichFaces.ajax("testForm:j_id_6",event,{"incId":"1"} );return false;" value="Test" type="submit" />
<input type="hidden" name="testForm_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="DiY2dVKs1zXBkLb43C7I439MwZ/wfbTcBNpwPlLjsh6prC/c" />
</form>
<div id="javax_faces_developmentstage_messages"></div></body>
</html>

How to share a ViewModel between different pages in jQuery mobile?

I am trying to share a ViewModel between pages.
Say I have pageA.html and pageB.html and a separate data.js file. pageA has fields bound (using Knockout) and after clicking a button it moves to pageB which also has some fields bound to the same ViewModel. I can't get this to work - what am I missing?
Of course I can keep all pages (data-role="page") inside a single .html file and it would work fine but is that the only way?
EDIT - pageB.html is a copy of pageA - I am trying to show the problem NOT having another login functionality in many pages!!!
This is the code:
pageA.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head lang="en">
<title>PageA</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script>
<script src="JS/data.js"></script>
</head>
<body>
<div data-role="page" id="login">
<div id="loginDetails">
<div data-role="fieldcontain">
<label for="username">
Username:</label>
<input type="text" name="name" id="username" data-bind="value: userid" />
</div>
<div data-role="fieldcontain">
<label for="pswd">
Password:</label>
<input type="text" name="name" id="pswd" data-bind="value: pswd" />
</div>
</div>
<a id="btnLogin" data-role="button" data-bind="click: login">Login</a>
</div>
<script type="text/javascript">
ko.applyBindings(S5.myViewModel);
</script>
</body>
</html>
pageB.html (largely the same as above but its javascript block doesn't seem to get called...)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head lang="en">
<title>pageB</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script>
<script src="JS/data.js"></script>
</head>
<body>
<div data-role="page" id="abcd">
<div id="loginDetails">
<input type="text" name="name" data-bind="value: userid" />
<input type="text" name="name" data-bind="value: pswd" />
</div>
</div>
<script type="text/javascript">
debugger; <-- THIS NEVER GETS CALLED!!
ko.applyBindings(S5.myViewModel);
</script>
</body>
</html>
data.js
var S5;
(function (S5) {
S5.myViewModel = {
userid: ko.observable('marcel'),
pswd: ko.observable('xxx'),
login: function () {
// ** DO LOGIN CHECK then move to pageB
$.mobile.changePage("pageB.html", { transition: "slideup" });
},
};
})(S5 || (S5 = {}));
jQuery Mobile uses Ajax Navigation to load and change views. When using multi-html page template, it loads first page (html file) entirely. However, for other views /pages fetched with Ajax, it loads contents inside <body> only, neglecting other tags i.e. <script>, <head> etc...
To solve your problem, move any extra JS libraries or code inside <div data-role="page">.

Resources