This topic is locked

New user questions

11/11/2008 8:59:22 PM
PHPRunner General questions
J
jasp author

I have a few questions, please go easy on me.
I have a table of music gigs, dates, times, locations and artists etc. I want an artist to be able to add his gig, date etc and then have displayed all gigs on the same date in the same location. It has to be really simple to do, but I just cannot work it out. I know we could do this with the advanced search function, but I would prefer it to be automatic, once the date and location of the gig are entered.
In the same vain, is there a way to auto delete records based on date, so that all gigs more than a week old are either deleted or moved to another table automatically.
Finally for now, I would like a user to be able to click on each artists name and be able to send them an e-mail, but without ever seeing the artists e-mail address. There are other topics on the forum mentioning this, but when I followed them I ended up messing everything up and had to delete the database and the project.
All and any help much appreciated.
Steve

J
Jane 11/12/2008

Steve,
please see my answers below:

  1. you can construct URL with advanced search parameters and redirect to this URL in the After record added event on theEvents tab. Use Redirect to another page action as a sample.

    To get the URL of advanced search results check following thread:

    http://www.asprunner.com/forums/index.php?showtopic=5704
  2. You need to use external scheduler like CRON for this purpose.

    Write a script that checks the date and delete unnecessary records. Use cron to run this script on timely fashion i.e. once a day.
  3. create new form with email subject and email body and then send email in the After record added event on the Events tab. Check Classified template in the PHPRunner and Reply function in this template.

J
jasp author 11/14/2008

Jane,
thanks for your reply, I have spent several hours trying to get the email to work, with no success. The search suggestion did not perform quite as I expected, but the email is most important.
I have 3 tables,
userswhere the list of registered members and artists and their details are stored (email field is email)
gigs where the artist put in their gig details, artist name, date, location, time etc
both tables have ID as the key field
what i want to be able to do with the email, is for a user to click on the artist name and this to open the email form, the from field filled automatically by the logged on username and the email address to be selected from the users table corresponding to the artists name clicked on. The actual email address should not be seen by the user.
I have tried following the classified template but have so far been unable to make any progress.
Hope you can find time to help.
thanks,
Steve

J
Jane 11/14/2008

Steve,
here are some tips:

  1. set up artist name as custom on the "View as" settings dialog on the Visual Editor tab.

    Here is a sample:
    $value = "<a href=\"emailform_add.php?artist=".$value."\">".$value."</a>";


2. then check $_REQUEST["artist"] in the Add page: Before process event on the Events tab, select email from users and save it in the $_SESSION variable:

if (@$_REQUEST["artist"])

{

$str = "select EmailField from users where Name='".$_REQUEST["artist"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$_SESSION["EmailField"] = $data["EmailField"];

}



Then use $_SESSION["EmailField"] in your event.

J
jasp author 11/20/2008

Thanks Jane,
e-mail sort of working now, just have to read some more to format it properly, have now bought the template pack so dumb questions moved to the members template forum, at least for the time being.
cheers,
Steve

J
jasp author 11/22/2008

Jane.
I have followed your suggestions beginning with the href... and can now send mail to the users.
what I am trying to do at the moment is get the logged in user included in the email subject line and this echoed back into the e-mail form fields.
I cannot get the echo to show the username, but the text part of the subject line echo´s fine, as does the message and the email field when I add them.
Also the echo´s show at the top of the page, not in the fields and only the typed "message" is recorded in the list view of the email form.
I have spent nearly 2 days on this and thrown by php fro dummies book through the window.
Any pointers would be much appreciated, the code I have written in the before record added section is below
[codebox]$email=$_SESSION["Email"];

$message=$values["Message"];

$subject="Message from user".$values["Username"];
mail($email, $subject, $message);
echo "$subject, $message";
return true;[/codebox]
Thanks,
Steve

J
jasp author 11/23/2008

solved most of these issues myself (I'm doing better without the php book)
for anyone as dumb as me, looking to do something similar, here's the code, if anyone has improvement ideas, they would be welcome.
[codebox]$email=$_SESSION["Email"];

$message=$values["Message"];

$subject="Message from user ".$_SESSION["UserID"];

$values["subject"]=$subject;

$values["Email"]=$email;

$values["maildate"]=now();

mail($email, $subject, $message);

[/codebox]