Let's say I have sugarcrm cases where I know what the case id and or number is.
I want to use email to sms to send to the techs what their work is. So, the link that needs to be sent must have the id and number in it. I want to send them to a simple PHP page that just has a dropdown menu with the two options accept and complete.
so if they receive the sms, they click on the link, it takes them to the page where they click on dropdown to accept the case.
Updating from the PHP is easy: it's just an update my sql query. I need to know how to send header or info in the link that the tech receives.
something like http://tech.com/caseupdate.php?case_number?case_id
so I can use that case number/id when updating
You need something like this:
Each variable in the query string should be separated by an & as +War10ck said
i.e:
http://tech.com/caseupdate.php?case_number=[num]&case_id=[id]
Then in your PHP you can get those variables using $_GET[].
<?php
if(isset($_GET['case_number']) && isset($_GET['case_id'])) {
$casen = (int) $_GET['case_number']; // assuming you need an Int value
$caseid = (int) $_GET['case_id'];
/* do your MySQL thing here now with $casen and $caseid */
}
?>
Dont know if this is right but got it working by doing the following
<input type="hidden" name="casen" value=<?php echo $casen;?>>
Thank you all for your help.
This si an excellent site for newbis to learn and get help in a direction to solve issues.
Related
I need for my current project a link that provides 2x timestamp(MySQL) 1x integer and 2x char. I know how to send an email with PHP but I don't know how to put all types together in one link. After someone clicked it, it should direct you to another PHP site in which I want to call a procedure. I should be save to, therefore maybe hashing?
An example:
http://examplesite.com/teachers/accepted.php?begintime=...,endtime=...,id=...,rndchar=...,rndcharv2=...
I hope someone could help me :)
<?php
$link = "Link Text";
mail($to, "subject", $link,$headers);
?>
Then on accepted.php you will get the query strings using $_GET then if they are all set and not empty, u do what u need to do
Check the following code. I want to display the send mail parameters like mail, subject and message in HTML page. Please let me know how can i display it in HTML
// send email notification
if (($ed['notify_email'] == 'true') && ($ed['notify_email_address'] != ''))
{
$email = $ed['notify_email_address'];
$template = event_notify_template('email',$ed,$ud,$od,$loc);
sendEmail($email, $template['subject'], $template['message'], true);
}
You can use PHP's echo or print methods to display variables.
<?php echo($myVariable); ?>
or
<?php print($myVariable); ?>
If you want to perform your sendmail action in one php page, then redirect to another and show the data, then you need some means of storing it between views.
if your sendmail is successful store a record of it in your database, and pass the key for that record to your next php page. In that one, query the data for that key, get the result and display it using echo or print.
Similar to above, but store the data in the user's session (not really advised), and display it on the next page using echo or print.
Don't store the data, but pass it along to your next page as GET key/value pairs (not really recommended either), access it in the $_GET[] array and display it using echo or print.
The best solution in your situation is option 1. Store the record, look it up when you need it and display it. It's more secure and you're not putting the user's data in session or passing along in the query string. Plus it gives you a historical record in your database of actions in your site.
I've just designed my first form in HTML and a PHP page to display the results. In the form the user inputs some codes in response to some questions, a bit like a multiple choice, so for example, these are "ABC". The PHP page displays the code to the user as a link, which when clicked will go to a bookmark (a link within the same page) with the ID #ABC. This was achieved with simple manipulation of the PHP variable as follows:
<?php
$code = "ABC"
$part1 = '<a href="mywebpage.php#';
$part2 = '">Go to this code</a>';
$string = $part1.$code.$part2;
echo $string;
?>
(i.e. Link in the page says "go to this code" and when clicked will go to section with bookmark ABC)
This all works fine, but I simply need to know if there is a way of error trapping so that if a bookmark does not exist for the code entered, a message can be displayed to the user instead? Can this be done using the PHP variable, or do I need to use JavaScript? One work around may be to search the web page for the ID "#ABC'. Is it possible to do this? Another option would be to store an array of valid codes on the server then query this before setting the bookmark, but I want to keep it as simple as possible. Any help appreciated, thanks.
What you call a "bookmark" we call a hash. And when you say "go to a bookmark" you mean a hash change. Hash changes do not make an additional request to the server, it is all handled on the client-side, therefore this must be done with JavaScript and not PHP.
So let's just do some simple JavaScript on hash change window.onhashchange that will search for an element with that ID and if it's not found alert something.
window.onhashchange = function(){
if(!document.getElementById(location.hash){
alert("not found");
}
}
I'm a bit new to this so sorry if this has been covered already but i'm going around in circles searching.
I've had a look around learn t how to edit htaccess and use the get function, I then even found a plugin called redirection that did similar.
What I would like to do is if I have a URL http://example.com/file.php?id=blue
is to grab the id which is "blue"
then in a href link dynamically add it to the end of another url
Link Example
If someone could help show me or point me in the right direction on how to get the id blue and add it into a href that would be great.
Many Thanks
You have to use $_GET. People might be dicks about it here - but I had a hard time when I was first learning to program too. You'll get it, don't worry.
This is how get works (at least, all you need to know about how it works):
if you have the file index.php
if you add a query string to the end of it like index.php?id=1
You can access id=1 by doing the following in your code:
$id = $_GET['id'];
Similarly if the query string contains the following index.php?id=1&page=5&par=3&club=putter&upnext=tigerwoods
On the left hand of the equal sign is the Key(id, page, par, club, upnext) and on the right side their value(1,5,3,putter,tigerwoods)
One thing to remember is that when retrieving numbers from the query string they will always be of the string type, so you cant do something like
if ( $_GET['page'] === 5 )
you'll have to do
if ( $_GET['page'] == 5 )
and to echo it into a link:
$club = $_GET['club'];
if ( $club == 'NRA' ) {
echo "Gun Show";
echo 'Buy tickets to my gunshow ^^';
}
Hope this helps!
You can also do things like set your website up so that it has one template and use the $_GET parameter to determine which files to include into the content sections of the site via a switch command. I do this, but not across my whole site. For my user control panel, I do this to simply include only the file necessary (change email, update password, delete account, update profile, etc)
Cah'piche?
Use the $_GET parameter.
YAY!!
I have a PHP page that uses jQuery to let a user update a particular item without needing to refresh the page. It is an availability update where they can change their availability for an event to Yes, No, or Maybe. Each time they click on the link the appropriate jQuery function is called to send data to a separate PHP file (update_avail.php) and the appropriate data is returned.
Yes
Then when clicked the params are sent to a PHP file which returns back:
No
Then, if clicked again the PHP will return:
Maybe
It all works fine and I'm loving it.
BUT--
I also have a total count at the bottom of the page that is PHP code to count the total number of users that have selected Yes as their availability by simply using:
<?php count($event1_accepted); ?>
How can I make it so that if a user changes their availability it will also update the count without needing to refresh the page?
My thoughts so far are:
$var = 1;
while ($var > 0) {
count($day1_accepted);
$var = 0;
exit;
}
Then add a line to my 'update_avail.php' (which gets sent data from the jQuery function) to make $var = 1
Any help would be great. I would like to stress that my main strength is PHP, not jQuery, so a PHP solution would be preferred, but if necessary I can tackle some simple jQuery.
Thanks!
In the response from update_avail.php return a JSON object with both your replacement html and your new counter value.
Or to keep it simple, if they click "yes" incriment the counter, if they click No or maybe and their previous action wasn't No or Maybe decrease the counter.
Assuming your users are logged into the system I'd recommend having a status field in the user table, perhaps as an enum with "offline", "available", "busy", "unavailable" or something similar and use the query the number of available users whilst updating the users status.
If you were to do this you'd need to include in extend your methods containing session)start() and session_destroy() to change the availability of the user to available / offline respectively
The best way is the one suggested by Scuzzy with some improvements.
In your php, get the count from the database and return a JSON object like:
{ count: 123, html: 'Yes' }
In your page, in the ajax response you get the values and update the elements:
...
success: function(data) {
$("#linkPlaceholder").html(data.html);
$("#countPlaceholder").html(data.count);
}
...