Perl/PHP Thread

Cromewell

Administrator
Staff member
You can call ini_set to reset the value temporarily for your script. Put it in a shared function place if you have a lot of scripts.
 

Ankur

Active Member
Ok I want to know how can I open a new page on click of a button (not submit button) without Javascript?
Just need to use php! but how?
 

Cromewell

Administrator
Staff member
Why can't you use Javascript? The only method I know is to use the onclick event. You can make the button a link by using a form but that won't open a new window.
 

Ankur

Active Member
Why can't you use Javascript? The only method I know is to use the onclick event. You can make the button a link by using a form but that won't open a new window.
Mostly a user/hacker will disable JavaScript and then the button won't work. I do know the form action button type.
 

Cromewell

Administrator
Staff member
I don't know too many people that disable javascript anymore but if it's a concern and you don't mind not using a button you can use a normal anchor tag and put a target in it to open a new window.
 

Ankur

Active Member
Ok this is a bit off topic question, but do you know how to get drop down list on a text box that looks similar too the one like google.
Also how to disable a button when it is clicked? I use onclick="this.disable=true;", it works but the form values don't POST to the action.
 
Last edited:

Cromewell

Administrator
Staff member
Do you have a page I can look at for their drop downs? Their other controls look kind of jQuery themed but Google will have probably written their own library for it.

For your button add form.submit() to the onclick action.
 

Ankur

Active Member
Do you have a page I can look at for their drop downs? Their other controls look kind of jQuery themed but Google will have probably written their own library for it.
I haven't really seen other websites like that except yahoo and bing, I just want to retrieve data from the database and allow the user to move over the names with their up-down keyboard keys, same like google.
I found this http://www.roseindia.net/tutorial/ajax/jquery/autocomplete.html
works fine but it is mostly jquery, I just have a feeling I can do the same with ajax, css and php, but don't really understand much of jquery code to convert it.
Here is the output http://www.roseindia.net/ajaxexamples/jquery/autoComplete/
For your button add form.submit() to the onclick action.
But does it disable the button?
 

Cromewell

Administrator
Staff member
Ok I understand what you're asking for now. I thought you meant how they were styling their selects or something.

Yes, you can definitely recreate it on your own, jQuery makes it a lot easier though. (http://jqueryui.com/demos/autocomplete/)
The gist of what you want to do is have the textbox post to a backend php/asp/whatever page via ajax that queries a database and returns a list available options for autocomplete. You then present the options to the user and have an onclick that populates the clicked option into the textbox.

You leave this.disable=true; and add form.submit(). i.e. <input type="submit" onclick="this.disable=true; form.submit()" />
 

ayan

New Member
Anyone knows how endline marker works in php ? I work as a webdesigner, but i have years of experience on other languages closer to C, that don't have syntactic sugar.
My problem is , that i enter a text in a textarea, the text has newlines. When i search the string in php for the caracter '\n' or '\r', it doesn't find anything. I want to know how this works bitwise. Thank you in advance :D
 

Cromewell

Administrator
Staff member
Writing a newline is just the os newline but if you want your HTML page to have that newline you are probably looking for <br /> (though you may want to adjust your markup to use things like <p>).
 

Ankur

Active Member
I have a website in PHP which hosts user files, these files are in .docx format. My problem is to prevent downloading of this files.
example: my site sitename.com hosts a file filename.docx
So when a user types the URL sitename.com/filename.docx then that file starts downloading.
I just want to ensure that the user who is eligible to download can do it.
 

NyxCharon

Active Member
In terms of pure code, nothing really comes to mind. I mean you could make each user's folder there username, and when someone attempts to download that file check against that.

However, the better, (and imo more professional) way to handle something like this would be LDAP authentication, however this is something that needs to be setup on a server so unless you have root access to wherever your hosting this, it's not easily achieved.
 

Cromewell

Administrator
Staff member
Apache? Look at .htaccess files. Code wise theres not much you can do, its a webserver problem.
 

computer7

New Member
Anyone knows how endline marker works in php ? I work as a webdesigner, but i have years of experience on other languages closer to C, that don't have syntactic sugar.
My problem is , that i enter a text in a textarea, the text has newlines. When i search the string in php for the caracter '\n' or '\r', it doesn't find anything. I want to know how this works bitwise. Thank you in advance :D

In PHP if you define a string with single quotes, PHP will not interpolate variables within it (including the newline variable \n).

Make sure that when you do the searching, you use double quotes:

PHP:
$position = strpos($_POST['mytextarea'], "\n"); // <-- double quotes

By using single quotes, PHP will literally seach for \n and not new lines.
 

Ankur

Active Member
I have a query here,
I build a software with PHP recently, in that I have to upload a file and process it. It checks every word of the file and processes it accordingly.
This is what I do, at home.php page I have the upload button, the action goes to form_upload.php page, this page has the upload script and processing script (The one that checks the words of the file).
After finishing the whole process, after almost 10-20 seconds, it comes back to the home.php page.

The problem is, the user cannot see anything while this is going on, I want to show them progress bar or some progress. The problem is that there is loading of two different pages. home.php->form_upload.php->home.php

I can use AJAX, but won't that show my important code.
 

Cromewell

Administrator
Staff member
Last edited:
Top