sonesay
Oct 15 2007, 10:29 AM
I have 2 main pages Page A(events_locked.php) and Page B(add_attendance.php). Both are php files. Page A takes a post var from another page(not Page B ) and then used to query for displaying records in a mysql datase. This variable has set as a session variable because there is 1 <input type='submit' on Page A that will invoke a javascript function to open a new window. CODE <script LANGUAGE="JavaScript"> window.name="main_index";
function openFormWindow() { OpenWindow=window.open("add_attendance.php", "newwin", "height=250, width=400,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no");
var x = getElementByName("form1"); x.target="newwin";
x.submit(); }
As you can see the first parameter on openFormWindow() is Page B php file Im wanting to display. The php file has some database queries in it and uses that preivous set session var to identify what records i want. When I use the window.open() from javascript it creates a nice new window for me but I cannot assign any <input type='hidden' values in it. I am going to be using 2 or more buttons on Page A thats going to go to page B and i need to be able to able to identify what is being submitted to display correct content for the user. The post count on page B is 0 so there is no way I am able to grab them. heres the code for page B it might help in understanding what I am trying to do abit better. CODE <?php session_start(); // include database file include("includes/database_itrap.php");
$event_id = $s['event_id']; $s['ea_added_group'] = false;
// get list of members $m_query = "SELECT userid, username FROM users WHERE userid NOT IN (SELECT ea_user_id FROM events_attend WHERE ea_event_id =" . $event_id . ")"; $m_result = mysql_query($m_query, $link) or die("Cannot return users list");
// get event details $e_query = "SELECT * FROM events WHERE e_id = " . $event_id; $e_result = mysql_query($e_query, $link); while ($e = mysql_fetch_array($e_result)) { $e_start = $e['e_start'];
}
if ($p['mode'] == "") { $e_start = date("H:i:s"); }
?>
<html> <head> <title>Add Attendance</title>
<script type='text/javascript'>
function addUser(toGroup,fromGroup) { var listLength = document.getElementById(toGroup).length; var selItem = document.getElementById(fromGroup).selectedIndex; var selText = document.getElementById(fromGroup).options[selItem].text; var selValue = document.getElementById(fromGroup).options[selItem].value; var i; var newItem = true; for (i = 0; i < listLength; i++) { if (document.getElementById(toGroup).options[i].text == selText) { newItem = false; break; } } if (newItem) { document.getElementById(toGroup).options[listLength] = new Option(selText, selValue); document.getElementById(fromGroup).options[selItem] = null; } }
function saveGroup() { var strValues = ""; var boxLength = document.getElementById('group2').length; var elcount = 0; if (boxLength != 0) { for (i = 0; i < boxLength; i++) { if (elcount == 0) { strValues = document.getElementById('group2').options[i].value; } else { strValues = strValues + "," + document.getElementById('group2').options[i].value; } elcount++; } } if (strValues.length == 0) { return false; } else { document.forms['groupsform'].group_users.value = strValues; document.forms['groupsform'].submit(); return true; } }
function ckForm() { var tmp = saveGroup(); return tmp; }
function test () { alert(document.forms.groupsform.mode.value); } </script>
</head> <body onLoad="test();">
<form name="groupsform" method="post" action="events_locked.php" target="main_index" onSubmit="setTimeout('window.close()', 0000); return ckForm();"> <div align="center">
Event ID: <?php echo $event_id . " "; ?> Start Time: <input type="text" name="ea_start" value="<?php echo $e_start; ?>" size="10" />
<br />
<select multiple='multiple' size='10' id='group1' name='group1' style='width:150' onChange="addUser('group2','group1');" > <?php while($u = mysql_fetch_array($m_result)) { echo "<option value='" . $u['userid'] . "'>" . ucfirst($u['username']) . "</option>"; } ?> </select>
<select multiple='multiple' size='10' id='group2' name='group2' style='width:150' onChange="addUser('group1','group2');" > </select>
<input type='hidden' name='group_users' /> <input type="hidden" name="event_id" value="<?php echo $event_id; ?>" /> <input type="hidden" name="mode" value="" /> <input type="submit" name="save_group" value="submit form" /> <input type="submit" value="Close" onClick="window.close();" />
<br /> <br /> Post count: <?php echo count($_POST); ?> Mode: <?php echo $_POST['mode']; ?> </div> </form>
</body>
</html> I seem to be posting alot of issues with how I want to do things in web. I have read/seen abit of ajax but still not proficent in PHP, XHTML, or JS enough to want to dive into it at this stage. Im still only starting to understand the DOM. I look on the web for any examples to help but there is nothing close to what I want to do so far. I sometimes wonder am I going about this the wrong way. sorry for the rant please someone help me out.
Reply
galexcd
Oct 15 2007, 07:41 PM
Just to make sure I got you right... You have post data being submited to page A, and page A opens page B with javascript, and you want page B to have that post data? If this is it, there is quite a simple solution... Set the post data as get data when opening the next page with javascript (see below) and replace all $_POST's with $_GETS in page B. CODE function openFormWindow() { OpenWindow=window.open("add_attendance.php?<?php $firstrun=true; foreach($_POST as $i => $data){ if($firstrun)$firstrun=false; else echo'&'; echo $i."=".$data; } ?>", "newwin", "height=250, width=400,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no");
var x = getElementByName("form1"); x.target="newwin";
x.submit(); } If this is not what you meant please re-explain what exactly you are trying to do...
Reply
sonesay
Oct 15 2007, 08:20 PM
Yes thats right I'll give that a go now thanks ^^ Update: I've tried adding those line of code it seems to work but somehow the mode variable gets stuck and cannot be changed. It gets set to 'add_on_time' on the URL for 'mode' even when I click the second button to invoke changemode('add_late'). I do get the alert in the function that tells me alert(document.forms.form1.mode.value) is set to 'add_late' but once the page gets created its still set mode='add_on_time'. I've tried to change $_POST to $_GET and $_REQUEST but still no luck Script from Page A CODE <script LANGUAGE="JavaScript"> window.name="main_index";
function openFormWindow() { OpenWindow=window.open("add_attendance.php?<?php $firstrun=true; foreach($_POST as $i => $data){ if($firstrun)$firstrun=false; else echo'&'; echo $i."=".$data; } ?>", "newwin", "height=500, width=400,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no");
var x = getElementByName("form1"); x.target="newwin";
x.submit(); }
function modechange(action) { document.forms.form1.mode.value = action; alert(document.forms.form1.mode.value); openFormWindow(); } </SCRIPT>
php form
echo "<form method='get' name='form1'>"; echo "<input type='hidden' name='event_id' value='".$e['e_id']."' />"; echo "<input type='hidden' name='mode' value='Default' />"; echo "<input type='submit' value='Add On Time' onclick=\"modechange('add_on_time');\" />"; echo "<input type='button' value='Add Late' onclick=\"modechange('add_late');\" />"; echo "<input type='button' value='Add End Time' onclick='openFormWindow();' />"; echo "<input type='button' value='Add Leave' onclick='openFormWindow();' />"; echo "</form>";
Script from Page B (testing output) CODE Post count: <?php echo count($_POST) . " "; ?> Get count: <?php echo count($_GET) . " <br /> "; ?> Request count: <?php echo count($_REQUEST) . " <br /> "; ?> Request mode: <?php echo $_REQUEST['mode']. " <br /> "; ?> Post mode: <?php echo $_POST['mode']. " <br /> "; ?> Get mode: <?php echo $_GET['mode']. " <br /> "; ?> for some reason i still get the URL add_attendance.php?event_id=4&mode=add_on_time from using the first or second button. The changemode() does alert a new value is set to 'mode' but it still isnt saved on the newly open window. I have tried using sessions but since Javascript was used to make the page no session variables are available on the new window. UPDATE: Sessions seems to work now on window.open pages. It worked first time round then somehow i butched up my code and it stoped working. I messed it up so much I had to revert back to yesterdays backup. Well ima give it another go.
Reply
sonesay
Oct 16 2007, 10:10 PM
Just an update. I guess the problem seems to be my function modechange() somehow not working with the openFormWindow(). I dont know if its because the very first page (Not Page A thats events_locked.php) only sends 1 post variable (event_id) so the function loop in page A for post dosent include 'mode' somehow. Well my current porblem now is I need to be able to set the <input type='hidden' name='mode' value so I can control what gets displayed on attendance.php (Page  . My modechange() does alert me that its changed but when page B gets created its not set and somehow always defaults to mode='add_on_time' value no matter what button I push on page A (add on time button or add late button). Heres an image it might give a clear idea of what im trying to do. If i can control the 'mode' to = 'add_late' I can set the default time to current time.  Edit: I spend the day reading up on abit of ajax and found an easy example. I backed up the files at this current stage since I still cant get it to work and am going to try to do it without using a pop up window. I think keeping it simple and working on the same page will see the site get done quicker. I can always go back to it and try get a working version of a pop up window at a later date.
Reply
Similar Topics
Keywords : php js pages hidden input values- Protect Pages
- HOW? (20)
I create certain pages for my web-site, and I would like to protect them that no one can hack or see
their source codes. So, if everybody knows how to do it, please post a reply over here. List of
the best ways, I can do it. Thanks....
Dynamic Php Pages
- Nice tutorial (5)
This is a really good tutorial on making php pages that normally appear as
www.domainname.com/links.php appear as www.domainname.com/index.php?page=links
http://nuwen.com/tutorials/php-dynamic-pages ...
Pagination
- ? (3)
2 Pages Into One
- how? (10)
Hello, now this may be a stupid question but i'm very new to php so i need some help. what
i'm wanting to do is combine 2 pages in to one. like for example the install.php for
invisionpower board it starts with one page and you click continue and it gives you a whole new page
but if you look at the url you are still using the install.php file but it has somethinglike "?a=2"
at the end. how can i do this. Thanks...
Php Pages Problem [resolved]
- Please help me im stuck ;-( (5)
Hi, i have been working with a wap forum script, translating from russian and fixing errors etc..
but now im stuck, the problem is with the pages while viewing a forum.. Let me explain.. the pages
are set to show ten topics per page which all works fine as you can see in these screenshots: page
1: page 2: The problem occurs when there are PINNED topics (with the redish folder), it will
show ten topics but also the pinned ones on page one, and the "Next" link will appear before it
should leading to a blank page where there should be topics but they are still on th...
[php] Hidden Fields?
- (4)
well what is hidden fields for.. i see alot of em in sources... what purpose do they server? how
to use em? etc? well can any one help me out here =?...
Php Pages Permission On Apache Server
- PHP pages permission on Apache Server (1)
Hello, I want to know what permissions for PHP pages should be given on Apache web server so that
PHP pages can be executed. If PHP pages are in a folder, what permissions should be given for that
folder? ...
Passing Values By Get
- (16)
I have problem I've been doing some programming in php that is something similar to registration
but whenever I want to check something it seems like variables are not passed or that the php
variables are empty I am using get instead of post however I am also considering to switch to post
as I cannot find an error. Anyone had similar experience that he could help me? Thanks in advance....
[php](simple) Using Functions To Combine Values In A Form
- Really simple example on how to combine values with function (2)
I just learned this simple method on how to use functions to combine two values from a form. First
we create ourselves a simple POST form CODE <form method="POST"> Name:
<input type="text" name="nickname"> Location: <input
type="text" name="location"> <input type="submit"
value="Input"> </form> Now we add this php to that same file CODE
<?php $nick = $_POST['nickname']; $location =
$_POST['location' ...
Putting Data Of 2 Pages In Mysql At Once
- (1)
suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but
after taking input, it will not put the data in mysql .. but it will take to the next step..
page.php?part=2 (if any field is left blank, it will not go to next page.. ) . and there also some
fields.. after the user has filled that form also, then it will insert all data (from part1 and
part 2) in mysql. i want to ask, how i can collect data from 2 pages and put in mysql at once....
Include And Values
- (3)
hi everybody, i am new to php programming, i have this code in page number 1: CODE <?php
$pages = array( 'number1' => 'number1.php',
'number2' => 'number2.php', 'number3' =>
'number3.php', 'number4' => 'number4.php',
); if (isset($_GET['page']) &&
isset($pages[$_GET['page']])) {
include(...
Securing A Php Script Proccessing Input
- I need help and advice (7)
Hi everyone I like to experiment with php, been doing so for about a year but im not clued up on
security yet, i can use str_replace() to take out parts of strings i dont want like html and JS code
inserted by users, and i know how to use stripslashes to take out slashes from input strings but
this doesnt seem to be lock-tight security to me. There has to be something more to protect my
scripts against malicious users. I belive its possible to use the "or_die()" function for
connecting to an sql table to prevent the error messages being shown to users, as error message...
Request Script: Short Or Full View Without Sql
- partial hidden content until clicked to view more (2)
I'd like to request the following "behavior" in PHP if at all possible. I have a content that
shows QUOTE Mary had a little lamb and it was white as snow. Click here to see more(link) And
when the "link" is clicked I would like to see the full view. QUOTE Mary had a little lamb and
it was white as snow. The quick brown fox jummped over the lazy dog. Click here to see less(link)
This time the "link" will shrink and show only the short view. I made style.css class HIDDEN where
in the page does not show, but still part of a file. The reason for this ...
Converting Characters In A Variable To Individual Values In An Array
- turning variables into arrays (2)
Say I have a variable such as $nav_item and it had to contents Home . IE: CODE
$nav_item = 'Home'; How would I make so that $nav_item was an array and
had the following contents? CODE $nav_item = array ('h', 'o',
'm', 'e'); With the case changing (ie H would become h and U
would become u ) EDIT: Okay found out that I could change the case with
array_change_key_case ($nav_item, CASE_LOWER); ...
Search Site Pages Using Keywords?
- (6)
We're doing a "Mock" e-commerce site for our project in Web Development and I was wondering how
to make a Search form like the ones in many sites. There will be a Search textbox and a button in
the form which will accept a string (keywords) which will then be processed by a script. If there
is a match, a page containg the keywords will be displayed. Is there a way to do this using PHP or
is there an existing free script out there already? Thanks very much....
Cleaning User Input With Regex
- (1)
As anyone who works with user input knows, not everyone who submits information makes it look
proper. One one of my web forms, I parse all the needed fields that I wish to be title cased; their
name, address, city, etc. I use this to perform this action, which works nicely: PHP Code: CODE
$string = ucwords(strtolower($string)); This fixes the input if
the user types in all caps or all lowercase. There is a problem I have been noticing about those who
enter a generation after their name, such as "Bill Warner III". The above functio...
Changing Include Tag On All Pages
- (11)
I want to change an include tag (include menu.htm) to include menu.php on all my pages on my
website. Is there any fast way to do this, or do I have to edit all of my pages manually?
/unsure.gif' border='0' style='vertical-align:middle' alt='unsure.gif' /> ...
Parsing .html Pages
- (9)
This isn't really that urgent but I was wondering, I read somewhere that you can configure you
server to pars all html pages for php code, and I was wondering if that was true, and if trap17 has
that feature enabled?...
Blocking Pages & Making Ranks
- (4)
I would like to know how and where to put the code that would block certain pages so people could
only get to them if they logged in. And I would like to have ranks on the site and when you get to a
certain rank you get more options like being able to add members and stuff. And also. I would like
some code for a news sytem for the homepage. Like where you have to be logged in to post something
and only people with certain ranks will have access to it and only certain people can delete it. I
would like to be able to make it so on the members page it displays members and y...
Securing Pages
- (2)
just wondering if there is a easy safe way to secure some webpages. i have a payment facility on my
site which is linked through paypal. when the member has paid they are taken back to my site "thanks
your payment has been successful page", once its went to this page the item is no longer listed on
my site. now i have found away people can mess with this using the url. this means people can
change just a few digits in the url and and mess the listings up on my site. after payment has been
made the member is redirected to:- mydomain.com/class/thanks_paypal.php?myprod_...
Php Classes
- Access the same class instance over multiple pages (1)
Hey everyone. I am having some trouble accessing the same php class instance in more that one page.
This is for my login script and what i need to do is be able to call the classes logout function
from a separate page. What i have tried to do is create a new .php page and include the class file
and then make a new class and call logout. This does not work because it does not log out the
current user which is my problem. Can anyone help me fix this or know of another way to do it?
Below is my class file CODE <?php // member class // handlers member logo...
Pages In 1 File
- ?? (9)
I know its possible to put many pages inside 1 file. But how? Lets say you have a guestbook with
different pages for signing and viewing. How to make so those pages are in 1 file? /huh.gif"
style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" />...
Embeding Pages
- (3)
Is there a way to have php act as an iframe? I dont want to have to change every single page when i
want to move something around. If anyone can give me a tutorial or somethign telling me how that
would be great, or ven another way of doing this without frames....
Looking for php, js, window, open, pages, trouble, set, hidden, input, values, window,
|
|
Searching Video's for php, js, window, open, pages, trouble, set, hidden, input, values, window,
|
advertisement
|
|