Hi im trying to do a SMS feature for my site. This code works well.
https://www.isms.com.my/isms_send.php?un=xxx&pwd=xxx&dstno=".$number."&msg=".rawurlencode($txt)."&type=1"
Although this code doesn't
https://www.isms.com.my/isms_send.php?un=xxx&pwd=xxx&dstno=".$number."&msg=".$msg."%0A".rawurlencode($txt)."&type=1"
As you can see in the &msg= im trying to send 2 variable but the site tells me there is an error of MISSING PARAMETER. How can I properly input that 2 variable for the same parameter?
I guess you want to send a multi line text message with $msg on the first line and $txt on the second.
As per the sparse documentation the end of line character is %0D instead of %0A.
One other remark: the documenation states that the msg parameter must be url encode, so shouldn't you use rawurlencode($msg) as well.
So, all in all the code should probably look like:
"https://www.isms.com.my/isms_send.php?
un=xxx&
pwd=xxx&
dstno=".$number."&
msg=".rawurlencode($msg)."%0D".rawurlencode($txt)."&
type=1"
Note: I've put it on multiple lines for readability only.
Related
I am trying to parse out the middle of the referrer information just to check from where the form submission is coming from.
Consider that the referrer is "https://www.somewebsite.com/someform.php
And what I want to extract is the part between those first two "//" and the next one "/".
I can get the string position, but how can I do a quick piece of code that will just parse out the part I need without several steps?
$ref=strpos($_SERVER['HTTP_REFERER'],'://');
gives me 5 (as the position where the "://" is found.
I want to use something like substr(string,start,length) the part out that is needed to get the pure referrer
the part that says "www.somewebsite.com"
without all the extra lines of code
used it
echo $_SERVER['HTTP_HOST'];
I'm a little unsure of how to word this one but essentially, I want to achieve the following:
http://my.website/?url=http://another.website/?var1=data&var2=moredata&id=119
And for the URL variable to be: http://another.website/?var1=data&var2=moredata&id=119
Naturally, PHP sees var2 and id as new variables. This would be used to pass a full URL from one page to another, however, it poses an issue when the page already has its own variables in the URL!
Any help appreciated!
You need to encode the secondary url which you're putting inside the url variable when you create it. This will ensure it doesn't contain special querystring characters that the receiving website will misunderstand. If the code in my.website is PHP too then the urlencode function (http://php.net/manual/en/function.urlencode.php) is your friend. For example:
urlencode("http://another.website/?var1=data&var2=moredata&id=119")
produces
http%3A%2F%2Fanother.website%2F%3Fvar1%3Ddata%26var2%3Dmoredata%26id%3D119
which will not be misunderstood by the PHP code reading it as containing further separate variables.
I want to create a PHP script that grabs the content of a website. So let's say it grabs all the source code for that website and I say which lines of code I need.
Is there a function in PHP that allows you too do this or is it impossible?
Disclaimer: I'm not going to use this for any illegal purposes at all and not asking you too write any code, just tell me if its possible and if you can how I'd go about doing it. Also I'm just asking in general, not for any specific reason. Thanks! :)
file('http://the.url.com') returns an array of lines from a url.
so for the 24th line do this:
$lines = file('http://www.whatever.com');
echo $lines[23];
This sounds like a horrible idea, but here we go:
Use file_get_contents() to get the file. You cannot get the source if the web server first processes it, so you may need to use an extension like .txt. Unless you password protect the file, obviously anybody can get it.
Use explode() with the \n delimiter to split the source code into lines.
Use array_slice() to get the lines you need.
eval() the code.
Note: if you just want the HTML output, then ignore the bit about the source in step 1 and obviously you can skip the whole eval() thing.
i have a download.php file which gets and opens files. i have a problem is that files were named using '&' in the file name so i get file not found when trying to access files with '&' in them.
example: download.phpf=one_&_another.pdf
in the download.php file i use get to the the file name ($_GET['f']) the example above throws the error file not found if i change the file name to one_and_another.pdf it works.
Yes renaming would be nice if there wasnt a whole lot of these files named this way.
I need to know how to ignore the fact that '&' doesnt mean im about to pass another var in php.
If you can control the query strings, you need to URL encode the ampersands so they look like this:
download.php?f=one_%26_another.pdf
Then look for $_GET['f'] as usual. Otherwise a literal ampersand & would break $_GET into
{ 'f' => 'one_', '_another.pdf' => '' }
You will probably just need to urlencode() the & properly in your links:
download.php?f=one_%26_another.pdf
Rule number 1 for accepting user input: do not trust it.
Refer to this StackOverflow answer for your solution.
I am sending two data to my php from my javascript:
http://forum.research.bell-labs.com/zeeshan/publication/phpwithmysql11111.php?rowid=BL09.00001,0
1) BL09.00001
2) 0
How do I recognize them separately in my php?
I was trying to do:
$job=$_GET[rowid];
echo($job);
this gives me both the fields.
Just split $GET['rowid'] on the comma. See:
http://us2.php.net/manual/en/function.explode.php
I'd say you need to name the second parameter as well as the first in your GET request.
Use a URL like this: http://forum...../phpwithmysql11111.php?rowid=BL09.00001&other=1
Then, $_GET['rowid'] should be BL09.00001 and $_GET['other'] should be 1.