play_
-
Posts
717 -
Joined
-
Last visited
-
Days Won
1
Posts posted by play_
-
-
A form is filled and the information is emailed to my address.
The problem is it goes to the spam folder.
Is it a problem with the email filter?
I suppose I could whitelist the email address the server uses to email the info, but then spam would get through as well.
Any ideas?
-
So you want to display them next to each other instead of on top of each other?
-
Ideally, i would like to be able to have www.example.com/users/john instead of www.example.com/users/view/id/john
I really don't see what's wrong with the latter there nor any real way around it.
It would be easier for people to remember.
I also think shorter is neater...but if there's no way around it...then there isn't. i've sat and tried to think this out for ~2hrs =(
-
Creating a basic MVC framework.
I may confuse myself while asking this, so bare with me if this is confusing for you also...
As far as i understand, the URLs are in the following format:
www.example.com/controller/method/args
My goal here is to not show 'method' in the URL if it's not necessary.
For example,
www.example.com/contact
instead of
www.example.com/contact/view.
This is OK. I can accomplish this. But problems arise when I want to pass arguments in the URL.
Say I have the URL:
www.example.com/users <----- this would by default, user the controller 'users' and call default method, 'view'..just list all users.
But say i want to view a user.. John.
www.example.com/users/john
How can I make my script know that 'john' is an argument, and not a method? The only way I can think of this is if I always have a method in the url .. like www.example.com/users/view/username/john
As of now, my script breaks up the URL at / and the first element in the array is is the controller. It calls the controller with the other arguments.
so www.example.com/users/john. The script would do (simplified)
$controller = 'users'
$controller = new $controller('john')
the 'Users' class would then see if 'john' is a method. If it is, call it, if not, then call the default method (view) with john as argument...
but what if I have a method called 'edit' and someone's username is edit? then www.example.com/users/edit would be a problem.
So my guestion to you guy is... how do you deal with this issue?
If you have www.example.com/users/edit, how do you let the script know that 'edit' is someone's username and now a method to call?
Do you pass the method in the url like so www.example.com/users/edit/edit ?
Or if you have worked with a framework (Zend, cakePHP, Symfony, CodeIgniter, etc), how does the framework handle it?
Ideally, i would like to be able to have www.example.com/users/john instead of www.example.com/users/view/id/john
-
thanks.
yea not sure which one of those 2 to do yet.
trying to keep this as simple as possible
-
Hello. Trying to learn MVC better by creating my own little framework to understand how it works.
Things were going OK til now.
I have a base class:
<?php /** * Base class most classes will extend from. * Simply put, this class just has methods that * most, if not all, classes will need. */ class Application { public function includer($path) { if (is_readable($path) == true) { include_once($path); } else { die("404 not found =["); } } } ?>
So the above method 'includer' just sees if a file exists/is readable and if so, include it.
Here's where I am using said method.
class Index extends Application { function __construct($method = 'view') { // load the index model include(ROOT . '/app/models/model.index.php'); // Invoke requested method. $this->$method(); } public function view() { $name = 'Smith'; $this->includer(ROOT . '/app/views/view.index.php'); # Problem here, i think } }
view.index.php just contains
<?php echo $name; ?>
All that is called from the index page, with this line of code
Application::includer($controller_path);
Now, in line
$this->includer(ROOT . '/app/views/view.index.php'); # Problem here, i think
If i get rid of $this->includer, the script will work and say 'Smith'.
If i have $this->includer(...) or parent::includer(...), it doesn't work.
why?
-
Sorry for not being so clear.
What I'm trying to is, i'll have a link. say
<a href="1.mp3">click to download</a>
When i click the link, instead of a download dialog popping up or having the file play in the browser, i want the browser to go to download.php
What is happening now:
When i click the link:
- page hangs in firefox.
- Chrome plays the mp3 file in browser
-
Didn't seem to work =(
-
This is my first attempt at mod_rewrite.
What I'm trying to do is make it so that when the user clicks any mp3 link (example, 1.mp3), mod_rewrites redirects that to download.php
I this in .htaccess:
RewriteEngine on RewriteRule *.mp3 download.php
if I go to http://localhost/1.mp3, the page hangs. Firefox shows the 'loading' sign on the tab, like it's about to load the other page, but it doesn't.
any help would be great. thanks
-
$_SERVER['query_string'];
-
I'd like to convert mp3's and possibly other audio formats into AAC, and clip/trim the audio file.
Should i use CGI for this or the exec() and pass the file to another program in the server that will do this?
Never really touched exec() but have heard horrible things about it.
Or is it possible to do this via PHP alone?
And, how can i check to verify the file is either mp3 (or WAV, for example)? Trying to check beyond the extension here. (i use exif_imagetype for images..wondering how to get the same kind of verification with audio)
thanks.
-
Will try. thanks
-
-
Hi.
I am developing a Private Messaging system.
I am not sure how to implement the 'reply' functionality. I see two ways of doing this (also, this is all in ajax):
John PMs Jane:
"Hi jane"
I would store in MySQL (simplified for simplicity's sake)
messageID (int),
senderID (int),
recipientID (int),
message (varchar)
Now Jane sees the message and clicks 'reply', where a textarea appears and she types and sends her reply. Let's say she writes "Hi John". (shown in image attached)
Now, because she is replying to a message john sent, i would ideally want to include the original message john sent her ('Hi Jane').
What i'm trying to get at: How to show John his original message ("Hi Jane")?
option 1:
Use jquery to get the text of the div that holds the message(which returns 'hi jane', from the image attached). pass that text via ajax to the php script. prepend the text to the new message jane typed. Use bbcode so i can later parse the original message from replied message. I do have a code for this:
if( isset($_POST['original') ) { $message = '[original-pm]' . $_POST['original'] . '[/original-pm]' . $message; }
So if the message being sent is a reply to another message, we prepend that another message(original) to the newly typed message.
problems with this:
[*]User can use firebug and change the content of the html/original message. then when he hits submit, jquery would grab whatever he wrote.
[*]User could accidentally write the BBcode [orignal-pm] ) on a message (although the odds are low)
option 2:
Instead of grabbing the original message with javascript, passing it to the php script and prepending it to the new message, just pass the original's message ID. Have a field in the database called 'parentID' and store it there.
problems with this:
[*]Again user could use firebug to change the messageID being passed via ajax. So say he changes messageID from 2 to 5. 5 could be another author's message, and thus, the recipient would be able to view the message.
[*]Could be bothersome having such hierarchy on database.
So how should i go about doing this
[attachment deleted by admin]
-
I helped him via IM.
just in case someone stumbles upon this in the years to come, the solution is below.
The problem was here:
<input type="text" name="translatorcharge" id="count" class="price" value="<?php echo $row_rsInvPending['jobtranslatorcharge']; ?>"/> <?php $table_name = $row_rsInvPending['fromtable']; $item_id = $row_rsInvPending['jobid']; ?> <input type="hidden" name="jobinvsent[]" value="<?php echo $table_name; ?>:<?php echo $item_id; ?>:<?php $_POST['translatorcharge'] ?>" />
He expected the user-entered value of the text input field to be in the hidden input field.
So he just made the text input's name an array, and on the processing page used parallel arrays ( $jobsinvent[], $translatorcharge[]) to update query.
-
function get_previouspage_link() { if($this->CURRENT_PAGE > 1) { $previous_page = $this->CURRENT_PAGE - 1; return "$_SERVER['REMOTE_URI']?currentpage=$previous_page"; } }
-
$allowed = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG); echo ( in_array(exif_imagetype($image), $allowed) ) ? 'good image type': 'invalid image type'; // $image above would be $_FILE['whatever']['tmp_name']
Here are the allowed types: http://us2.php.net/manual/en/function.exif-imagetype.php
-
I must ask:
You'll have people type @<user id> as opposed to @<username> ?
-
try replacing
$transcharge = $_POST['translatorcharge'];
with
$transcharge = $arr[2];
-
Your site needs to allow remote mysql connections.
If they do, they should have in their knowledgebase/FAQ the server to connect to.
-
no prob. report back with results! (don't forget to click 'mark solved' if youve solved it)
-
1. Did you check to see if the query is yielding the results you expect?
2. You're doing this:
<input type="radio" name="auth" id="radio" value="<?php echo "$auth";?>"> <input type="hidden" name="name" id="name" value="<?php echo "$name";?>" />
but on process.php, you should query the database for "auth" to make sure it exists, since a user could use firebug to edit the hidden field and give any value it wants.
And since you'll be querying the database already to make sure that auth exists, pull the username from it...
select clan_members.authid, clan_members.name from clan_members where authid = "$auth"
So, you don't even need to pass a hidden field for name.
Did that make sense? (its 6am and i haven't slept yet, so there's a chance it didn't).
Basically..
1. don't do '<input type="hidden" name="name" id="name" value="<?php echo "$name";?>" />'
2. Just pass <input type="radio" name="auth" id="radio" value="<?php echo "$auth";?>">
3. Youre passing the "$auth" to process.php. On process.php, select 'name' where auth = '$auth'
If these dont suit your needs for some reason, i'll analyze your code later when i wake up.
------------ also -------
<td><?php echo "$auth";?></td> <td><?php echo "$name";?></td> <td><?php echo "$rank";?></td> <td><?php echo "$flags";?></td>
You don't need quotes around variables. you can just have <?php echo $auth; ?>
You also have " <td><div align="center">" .. you can do <td align="center">
no need to clutter your html
-
Just tried your code and it worked fine. it displayed "The following numbers are prime: 3 11 29"
-
no prob.
E-mails going to spam
in PHP Coding Help
Posted