How to get parameter from this url? - php

normally it is working as expected, but while building my login page it is not working as I want to.
Well url is http://localhost/?page_id=96?msg=INVALID_PASSWORD_MSG
And I am trying to make it work this..but it is not working, I will be happy for every help :)
<?php if (isset($_GET['msg'])) { ?>
<div class="invallidpassword"><cite><?php echo $_GET['msg']; ?></cite></div>
<?php } ?>

I think you need to correct the question marks. Lets say you have a query page which retrieves page content from database. Then
It should be something like following.
http://localhost/query?page_id=96&msg=INVALID_PASSWORD_MSG
The first question mark added after the requested page, and the parameters are separated by &

Related

how to put two parameters by jquery in a link to use by codeigniter

i want to put two parameters by jquery in href of a link and then use by codeigniter, my code is below:
$("#user_comment_show").append("<li>"+...+'<a id="remove_link" href="<?php echo base_url().'my_site/remove_user_comment/';?>'+data.user_email_address+"/"+data.user_text+'">'+.....+"</li>"
i see data.user_email_address and data.user_text in source page but by select a link codeigniter shows me an error :
The URI you submitted has disallowed characters.
what's wrong with code and how to send these two parameters to my public function in codeigniter by jquery in a link. i appreciate to help me solve my problem
data.user_email_address && data.user_text find by ajax in database
my a link in source page
change into like this
$("#user_comment_show").append("<li><a id='remove_link' href='<?php echo base_url()?>/my_site/remove_user_comment/'+data.user_email_address+'/'+data.user_text+'>Your Link Name</a></li>")
hopefully this will work fine.

Laravel 3 how to include variables in flash message url

I have a form which is used to write to a database. I managed to successfully complete everything except including php variables as part of the url in the flash message:
if($sale->save() && $updateowed)
{
return Redirect::to('/')->with('flash_notice','Sale record id '.$sale->id.' created. <a href=/printmemo/'.$sale->id.'>Print Cash Memo</a>');
}
The first $sale->id is displayed correctly. However, the $sale->id inside the href prevents the form form redirecting to '/' and shows a blank message. Checking the database reveals the $sale->save() is indeed successful. I kind of know it's the problem with how I use quotes, however I'm unable to solve the problem. Any help is much appreciated.
You are doing it wrong, you should only pass the data to the session and build the tag from your view, for example you may pass the $sale->id form the controller using something like this:
return Redirect::to('/')->with('sale_id', $sale->id);
Then in your view where you want to show the link using $sale->id build it like:
<?php if(Session::has('sale_id')): ?>
<a href=<?php echo "printmemo/" . $sale->id ?>>Print Cash Memo</a>
<?php endif; ?>
If you are using Blade then use blade syntax to echo the id.

How to create a dynamic link?

I'm trying to create a link that takes the user to two different pages depending is the user logged or not. Problem is I'm still new to programming and this is quite big bite for beginner like me but its something I have to do. I created something like this so far but either way I suck at searching or there just isnt specific information for what I need
<?php if($userLogged){
echo '<a href="index.php" class="stylelink">';
}
else
{
echo '<a href="index1.php" class="stylelink">';
}
echo "Etusivu</a>";
?>
I'm also using Dreamweaver's login function that creates the MM_Username session and such, and Im not sure how to make the condition. userLogged is still an empty variable. Id appreciate any advice.
Thanks
-John
well, instead of using echo statements in the php tag you can write html and use php for outputting the value of the page like this
Etusivu
The $_SESSION['MM_Username'] works if you have included session_start(); at the beginning of the page and you can use the condition as above instead of $userLogged.

How can I capture/pass a keyword through a URL and pass it to a PHP page

I'm looking to pass a keyword from a HTML page to a PHP page through the URL string.
See example below to what I'm saying:
mysite.com/index.html?keyword=Google
the "Keyword" is Google and it needs to go over to my Thank you page.
mysite.com/thankyou.php
the code I use on my "thankyou" page is:
<?php $id = $_GET['keyword']; echo $id;?>
NOTE: I've visited and tried the links I found on the stackflow site... but none of them seem to work (asleast from what I've done with them). Am I missing any other thing when it comes to the code?
How do I get the current URL and then get the last words
how can i get the url if it is like this <keyword>?
How to pass a keyword from URL but keep it hidden? (Adwords)
If you could PLEASE provide a functioning example on a http://jsfiddle.net page so I can see how it works.
You need to have the get variable on the php page url, not the index.html page.
Example:
mysite.com/thankyou.php?keyword=Google
Alternatively you could write a html <form> and make a <input type="hidden" name="keyword" value="Google"> and grab it from POST instead of GET with PHP.
<?php $id = $_POST['keyword']; ?>

How to print a page using javascript for every php while loop?

I want to print a page using javascript in php while loop. Please help me by giving an advice.
eg:
$q=mysql_query("SELECT name, address FROM member_table);
while ($r=mysql-fetch_row($q)){
echo $r['0']."<br />".$r['1'];
echo 'javascript:window.print()';
}
But this is not working. Please help me.
I want to print the page similiar to Print But this should be automatic as while condition will bring more result in looping process
Is there any way to send the page directly to printer one by one from loop or other method. Please help me by giving an example
Could you provide more details on what you're trying to do. PHP is server side while javascript is client side. When php is done producing the page (loops or not) you still have just 1 page rendered. I am not sure what javascript:window.print() in the loop gives you.
If you want to trigger the page to print after the whole thing is rendered, you can put
<script>
javascript:window.print();
</script>
at the bottom of your page but not in your loop.
Don't use echo for javascript output.
<?php while { ?>
Javascript here
<?php } ?>

Categories