Gossamer Forum
Home : Products : Links 2.0 : Customization :

Modify.cgi - Use old data if fields left blank?

Quote Reply
Modify.cgi - Use old data if fields left blank?
Hello.

Been searching high and low on here for how to do this, with no luck.

When a person goes to modify their listing and forgets to re-input one of the fields, like the description for example, that field is printed blank on submission. So then I have to look at their old description and put it back in, which is a pain.

Is there a way to use the old data if a field is left blank when a modification is submitted? That way someone won't have to re-enter all their link info again (only the fields they want to change), and if they forget a to re-enter a field, it won't force the administrator to constantly add back in the missing field info.

Any help would be greatly appreciated. Thank you.

Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Basic HTML form codes:

Code:

<textarea name="Description" rows="40" cols="5"><%Description%></textarea>


OR

Code:

<input type="text" name="Title" value="<%Title%>">


You could also do something like the following in the sub process_form routine in the modify.cgi file:

Code:

if ($in{'Description'} eq "") {
$rec{'Description'} = $original{'Description'};
}




Regards,

Eliot Lee
Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Thanks for the quick reply Eliot.

So basically if I altered the subroutine, I'd have to define $original somewhere correct?

Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Look for $db_modified....

Regards,

Eliot Lee
Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Thanks Eliot, I just looked at the file. Understand completely now.

Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Well tried throwing the code below everywhere in the sub process_form part of modify.cgi, with no luck. It keeps telling me I can't have those fields blank, so obviously it is not pulling values. Any other ideas? Here's what I am using.

# If fields are left blank use old fields
if ($in{'Description'} eq "") {
$rec{'Description'} = $original{'Description'};
}

if ($in{'Title'} eq "") {
$rec{'Title'} = $original{'Title'};
}

if ($in{'URL'} eq "") {
$rec{'URL'} = $original{'URL'};
}

if ($in{'Contact Email'} eq "") {
$rec{'Contact Email'} = $original{'Contact Email'};
}

if ($in{'Category'} eq "") {
$rec{'Category'} = $original{'Category'};
}

Thanks!

Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Go into modify.cgi and below:

# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;

Add:

# If fields are left blank use old fields
if ($in{'Description'} eq "") {
$in{'Description'} = $original{'Description'};
}

if ($in{'Title'} eq "") {
$in{'Title'} = $original{'Title'};
}

if ($in{'URL'} eq "") {
$in{'URL'} = $original{'URL'};
}

if ($in{'Contact Email'} eq "") {
$in{'Contact Email'} = $original{'Contact Email'};
}

if ($in{'Category'} eq "") {
$in{'Category'} = $original{'Category'};
}





Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Modify.cgi - Use old data if fields left blank? In reply to
Thanks glennu, that worked perfectly! Appreciate the help fellas.