melting_dog
-
Posts
118 -
Joined
-
Last visited
Never
Posts posted by melting_dog
-
-
Thanks guys.
i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).
Anyone got any other ideas? Thanks
...but this is also strange because even if $_GET['comDiscussNo']; has nothing in it the if statement:
$discussIDtrans = $_GET['comDiscussNo'];
$discussIDpost =(int)$_POST['discussID'];
if ($discussIDtrans == null) {
$discussID = $discussIDpost;
}
else {
$discussID = $discussIDtrans;
}
should just pass it on to the else statement, making $discussID equal to the POST
weird...
-
Thanks guys.
i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).
Anyone got any other ideas? Thanks
-
Hi all,
I have a page that runs a query where users can send info via either a form (post) or from redirecting from another page (get).
The get function uses:
header("location:forumsDiscussion.php?$comDiscussNo");
to send content of the $comDiscussNo variable and appears to work fine: i can see the variable content in the URL.
but when i put these into if statements it doesnt run.
Heres the code:
<?php
$discussIDtrans = $_GET['$comDiscussNo'];
if ($discussIDtrans = null) {
$discussID=(int)$_POST['discussID'];
}
else {
$discussID = $discussIDtrans;
}
$sql = "SELECT * FROM discussion WHERE discussID ='$discussID'";
******ETC ETC ETC*******
Anyone have any ideas why this isnt working?
Cheers
-
Thanks.
Yeah...I really should have thought of that early
-
Is there anyway to make this work without converting the JavaScript variable to php?
(a javascript variable inside a value tag inside a form tag within php):
<script type="text/javascript">
var curdate = new Date();
</script>
<?php
echo '<table>';
echo '<form name="form1" method="post" action="forumsNewCommentProcess.php">';
echo '<tr>';
echo '<td class="headerCol">Date</td>';
echo '<td><input name="comDate" type="text" value="' + curdate + '" size="80" maxlength="150" /></td>';
echo '</tr>';
echo '</form>';
echo '</table>';
Any help would be appreciated!
Cheers
-
hmm, ill have to check out the javascript way or not use include on this page.
Cheers for the info!
-
Hi,
I have an include function that has all my header tags (<head>, html document type, css link, <html>, etc)
But I want to redirect my to another page later on in my code (in an 'if' statement).
I realise that you cannot use header(location:####) within the html tags. Is there another way to redirect?
Cheers.
-
ok so i solved the first issue. but the repeating issue is still a problem...any help would be appreciated
-
Hi all,
I have a form that i can fill with php variables i.e:
echo '<td><input name="pCode" type="text" value="' . $row['pCode'] . '" size="40" maxlength="120" /></td>';
But does anyone know how to preset a drop down list so the initial value is the php $row variable?
Cheers
-
Hi all,
Im constructing a JQuery drop down menu system and have come accross two problems. The first is that when the page first loads the submenu is visable (but works properly when i roll over it) and the 2nd is that I cannot seem to repeat the process for the the other items in the navigation menu - it only works for the first one.
Here is my code:
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(function() {
$('#nav li').hover(function() {
$('div.subMenu', this).show(400);
}, function() {
$('div.subMenu', this).hide(400);
});
});
$(function() {
$('#nav li').hover(function() {
$('div.subMenu2', this).show(400);
}, function() {
$('div.subMenu2', this).hide(400);
});
});
});
</script>
<div id="nav">
<ul>
<li><a href="index.php"><img src="images/homeBtn.gif" alt="Home"/></a>
<div class="subMenu">Return to the home page.</div></li>
<li><a href="about.php"><img src="images/aboutBtn.gif" alt="About"/></a></li>
<div class="subMenu2">Learn more about the SDM&A.</div></li>
</div>
Any help would be greatly appreciated!
-
Thanks!
This worked:
<?php
$sql = "SELECT COUNT(mailingID) AS cnt FROM mailinglist";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
?>
var sum= parseInt ("<?= $row['cnt'] ?>");
with the parseInt
Thanks for your help
-
Hi.
I need to use the total count of items from a table in an equation in javascript.
This is as close as I have gotten:
$sql = "SELECT COUNT(mailingID) FROM mailinglist";
$result = mysql_query($sql);
var sum= "<?= $result ?>";
var sum returns the correct number but preceded by Resource id# (i.e. Resource id #5) and I cannot use this for equations. Any one got any ideas on how to just get the number?
Cheers
-
Firstly, if you're going to use any $_SESSION data, you need to have session_start(); at the beginning of the script. Also, session_register() is deprecated. and should be changed to use the correct syntax (see below). And I can't think of any good reason to store a password in a $_SESSION var. Lastly, after a header() redirect, you should always follow it with exit(); to prevent the script form executing any further.
$_SESSION['name'] = $name;
Thanks Robert and Pikachu. I have updated the session_register to $_SESSION.
It seems as if the session_start wasw the problem: i had it on a thrid page that redirected from loginProcess.php but have changed it to where robert suggested.
So alls fine now but i might have to do some more testing...
Cheers
-
Hi all.
Im probably missing something here so forgive me if this is a noob question. I have created a login page for a site I am building at home with xampp. For the last week its been fine but just today when I try to use the login it redirects me to main.php - theres no such page in my folder structure.
my login looks something like this:
Login in page:
<form name="form1" method="post" action="loginProcess.php">
<input name="name" type="text" value="Name" size="40" maxlength="100" />
<input name="password" type="password" value="password" size="40" maxlength="100" />
<label><input type="submit" name="Submit" id="Submit" value="Submit" /></label>
</form>
loginProcess page (which doesnt actually get reached):
$name=$_POST['name'];
$password=$_POST['password'];
$name = stripslashes($name);
$password = stripslashes($password);
$name = mysql_real_escape_string($name);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE firstName='$name' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("name");
session_register("password");
header("location:loginSuccess.php");
}
else {
$wrong = '<h3 style = "text-align: center;">Sorry! Wrong Username or Password</h3>';
}
ob_end_flush();
?>
Oddly enough, when I put in an incorrect name or password it does redirect to the right page. - Just wierd
anyone know why this is happening?
-
Thanks. Thats worked a treat.
-
I'm trying to implement a code that will simply delete a row via a pre-entering an ID. Pretty simple, but I seem to be missing something so some other opinions would be appreciated.
The postID is sent from a form. So:
$postID=$_POST['postID'];
$postID = stripslashes($postID);
$postID = mysql_real_escape_string($postID);
$sql="SELECT * FROM $tbl_name WHERE postID='$postID'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
$sql="DELETE FROM $tbl_name WHERE postID='$postID' LIMIT 1";
$result = '<p>Successfully Removed</p><a href="index.php">Back to Home Page</a>';
}
else {
$result = '<h3 style = "text-align: center;">Sorry! No Posts with that ID were found.</h3><a href="removePost.php">Try Again?</a>';
}
ob_end_flush();
?>
Yeah so like i said probably something simple but any help would be greatly appreciated
Cheers
-
HI all,
Sorry this question might sound very 'newbie'.
I have an HTML hyperlink and when clicked i want to run a query that will display the results on the page the hyperlink links to.
Can anyone give me the basic structure of how this might be done?
Cheers
opening page with GET and POST
in PHP Coding Help
Posted
Thanks heaps Robert, that has fixed the problem of $_GET['comDiscussNo']; being null.
But any suggestions on why the $_GET isnt working?
Cheers again!